Jump to content

[SOLVED] Showing Pictures from a mysql database


dark22horse

Recommended Posts

Hi guys, thanks for your help before.  But im back again, with more problems. 

 

I am trying to get pictures out of my database, they are not actually pictures in the database, but I think just a reference to them.  I will show in my code.

 

This is my PHP page I using to display them. 

 

<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","");

//select which database you want to edit
mysql_select_db("car"); 

//select the table
$result = mysql_query("select * from car");

//grab all the content
while($r=mysql_fetch_array($result))
{	
   //the format is $variable = $r["nameofmysqlcolumn"];
   //modify these to match your mysql table columns
  
   $price=$r["price"];
   $description=$r["description"];
   $photo=$r["photo"];
  
   //display the row
   echo "$price";

   echo	"$description";

   echo "$photo";


}
?>

 

This is the information that is displayed from the php page. 

 

£150000this is a expensive114369546_58f1ef86b6_m.jpg$510000this is a description 461738934_0b4c73e6d9_m.jpg£222222here461738934_0b4c73e6d9_m.jpg

 

I know this is not very well organised, but I want to get the thing working before i make it look good.

 

cheers

Change:

 

<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","");

//select which database you want to edit
mysql_select_db("car"); 

//select the table
$result = mysql_query("select * from car");

//grab all the content
while($r=mysql_fetch_array($result))
{	
   //the format is $variable = $r["nameofmysqlcolumn"];
   //modify these to match your mysql table columns
  
   $price=$r["price"];
   $description=$r["description"];
   $photo=$r["photo"];
  
   //display the row
   echo "$price";

   echo	"$description";

   echo "$photo";


}
?>

 

To:

<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","");

//select which database you want to edit
mysql_select_db("car"); 

//select the table
$result = mysql_query("select * from car");

//grab all the content
while($r=mysql_fetch_array($result))
{	
   //the format is $variable = $r["nameofmysqlcolumn"];
   //modify these to match your mysql table columns
  
   $price=$r["price"];
   $description=$r["description"];
   $photo=$r["photo"];
  
   //display the row
   echo "$price";

   echo	"$description";

   echo "<img src='path/to/images/$photo' alt='' />"; //You need to implement the IMG tag


}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.