displaying images from database in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mparrett
Forum Newbie
Posts: 1
Joined: Thu Jul 09, 2009 10:11 am

displaying images from database in php

Post 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
Last edited by Benjamin on Sat Jul 11, 2009 1:54 am, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: displaying images from database in php

Post by flying_circus »

The syntax is incorrect.

Code: Select all

echo '<td><img src="' . $row['img_main'] . '" /> </td>';
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: displaying images from database in php

Post by pickle »

What does the HTML code look like after it's been generated by PHP?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: displaying images from database in php

Post by Benjamin »

:arrow: Moved to PHP - Code
Post Reply