[advanced search]
Results from the most recent live auction are here.
22 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Webmaster Tutorials
User Name
Password

Old 03-04-2006, 01:36 PM   · #1
asgsoft
NamePros Regular
 
asgsoft's Avatar
 
Location: At Home
Trader Rating: (36)
Join Date: Sep 2005
Posts: 806
NP$: 981.10 (Donate)
asgsoft is just really niceasgsoft is just really niceasgsoft is just really niceasgsoft is just really niceasgsoft is just really nice
Php Links + images form Mysql db

I know i was having troubles with this a while ago but as i found a way in a php book on how to solve it i thought i will share it.

lets say your db has a coloumn for websites and another for images and you want to make a list that displays all the info in the db including the website as a link and an image. well here is how to do it:

PHP Code:
<?php
$db
= mysql_connect("localhost", "root", "");
mysql_select_db("db_name");
// -----------------------------------------------

$result = mysql_query("SELECT * FROM table order by 'id'")or die(mysql_error());
$num_links = mysql_num_rows($result);
for (
$i=0; $i<$num_links; $i++)
{
//part 1
$row= mysql_fetch_array($result);
$id = $row["id"];
$name = $row["name"];
$email = $row["email"];
$website = $row["website"];
$description = $row["brief_description"];
$image_dir = $row["image_dir"];

//part 2
print "User Id : $id <br />";
print
"Name : $name <br />";
print
"E-mail : $email <br />";
print
"Website : <a href=http://$website>$website</a><br />";
print
"brief description : $description <br />";
print
"image is <img src='$image_dir'> <br /><br />";
}
?>


As you see in part 1 we got the data from the database. this is all what we need for now.

In Part 2 we print the data out that we stored before as variables. so it will view a block containing id,name,email,website,brief discription and an image.

For the link i used:
PHP Code:
print "Website : <a href=http://$website>$website</a><br />";
what this does is it writes website then makes a link command tellink it to hyperlink to the website that we got from the variable.

the same with the image image tag with a variable for the acctual image. so it looks like this:

PHP Code:
print "image is <img src='$image_dir'> <br /><br />";

I hope that helps someone.


Please register or log-in into NamePros to hide ads
asgsoft is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Great Scripts for Sale With Resale Rights! Zeeble Scripts For Sale 20 01-04-2006 01:39 AM
Hot Links SQL ( Web Directory Script ) License with $24.95 discount Ferman Scripts For Sale 1 10-23-2005 12:17 AM

Site Sponsors
Get Your Site Linked at LinkedKeywords.com Proof is in the Parking Buy Flash Arcade Game Script
Advertise your business at NamePros
All times are GMT -7. The time now is 12:54 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0