Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

How to pull images from MySql database using PHP

General discussions related to php

Moderators: macek, egami, gesf

How to pull images from MySql database using PHP

Postby NabilChicago » Sat Apr 05, 2003 7:59 pm

Hi,
I have a table in my database which is called raja_products, this table contains (productID, productPrice, productImage, productDescription).

productImage contains picture`s names of the products (eg, shoes.jpg). I already uploaded these pictures to a folder called images. What I`m looking for is a script that can display these images in my site.

Thank you[/url][/list]
NabilChicago
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Apr 05, 2003 7:51 pm
Location: Chicago

Postby bezmond » Sun Apr 06, 2003 12:11 am

Code: Select all
<?
mysql_connect("host","username","password) or die("Couldn't connect to mysql, whoops!");
mysql_select_db("databasename") or die("Couldn't open the database, did ya screw up?");
$query = "SELECT * FROM raja_products";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
$imagefile = $row["productImage"];

***you can insert variables for the other fields here too***
?>
<img border="0" src="imagesfolder/<? echo $imagefile ?>" width="640" height="480">
<? } ?>


Hope that works,
Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

Thank you

Postby NabilChicago » Sun Apr 06, 2003 11:38 pm

:lol:
Thank you very much, it works.
NabilChicago
New php-forum User
New php-forum User
 
Posts: 5
Joined: Sat Apr 05, 2003 7:51 pm
Location: Chicago

Postby bezmond » Mon Apr 07, 2003 6:18 am

Cool. Your welcome

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK


Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.