NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > Webmaster Tutorials
Reload this Page Php Links + images form Mysql db

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search
0 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 03-04-2006, 01:36 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
asgsoft's Avatar
Join Date: Sep 2005
Location: At Home
Posts: 881
asgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of light
 



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
$rowmysql_fetch_array($result);
$id $row["id"];
$name $row["name"];
$email $row["email"];
$website $row["website"];
$description $row["brief_description"];
$image_dir $row["image_dir"];
????: NamePros.com http://www.namepros.com/webmaster-tutorials/173492-php-links-images-form-mysql-db.html

//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 />"
????: NamePros.com http://www.namepros.com/showthread.php?t=173492
I hope that helps someone.
asgsoft is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


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
FREE Web Directory Script * Hot Links Sql ! Ferman Domains For Sale - Make Offer 3 12-04-2005 11:57 PM
Hot Links SQL ( Web Directory Script ) License with $24.95 discount Ferman Scripts For Sale 1 10-23-2005 12:17 AM

 
All times are GMT -7. The time now is 12:57 AM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger