Page 1 of 1

displaying images from database in php

Posted: Thu Jul 09, 2009 10:22 am
by mparrett
i am new to php mysql, i have set up a database and can retrieve all th information using php into an html table.

however i would like to display and image using a file location stored in my database..

i have

Code: Select all

 
  echo "<td>" . $row['Price'] . "</td>"; // this displays ok
  echo "<td>" . $row['Status'] . "</td>"; // this displays ok
   echo "<td>" . $row['img_thumb'] . "</td>"; // this displays the file location OK
 
what i want to do is display the image using src and my file location stored in "img_thumb",

i have tried the following but no joy

Code: Select all

 
 echo "<td>"<img src= . $row['img_main'] ./> "</td>";
 echo "<td>"<img src=" . $row['img_main']" ./> "</td>";
 
any help apreciated thanks mark

Re: displaying images from database in php

Posted: Thu Jul 09, 2009 11:17 am
by flying_circus
The syntax is incorrect.

Code: Select all

echo '<td><img src="' . $row['img_main'] . '" /> </td>';

Re: displaying images from database in php

Posted: Fri Jul 10, 2009 10:04 am
by pickle
What does the HTML code look like after it's been generated by PHP?

Re: displaying images from database in php

Posted: Sat Jul 11, 2009 1:55 am
by Benjamin
:arrow: Moved to PHP - Code