Jump to content


how to display picture from database

  • Please log in to reply
2 replies to this topic

#1 checkmodem12

  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 14 July 2006 - 03:53 AM

this is the code that shows the URL link of the picture that is in my database. is there a way to display so the picture appears and not just the link?


@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM test_mysql WHERE classification='crafts'";



while ($i < $num) {


<table width="100%">
<tr><font face="Arial, Helvetica, sans-serif" size="2">Name:<? echo $id; ?></font></tr>
<tr><font face="Arial, Helvetica, sans-serif" size="2">Description: <? echo $description; ?></font></tr>
<tr><font face="Arial, Helvetica, sans-serif" size="2">Price: <? echo $price; ?></font></tr>
<tr><font face="Arial, Helvetica, sans-serif" size="2">Picture: <a href="<? echo $picture; ?>"><? echo $picture; ?></a></font></tr>
<tr><font face="Arial, Helvetica, sans-serif" size="2">Class: <? echo $classification; ?></font><br><br></tr>



#2 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 14 July 2006 - 05:27 AM

First, using mysql_result is bad -- mysql_fetch_assoc() is better.  Second, I assume the picture column is a blob?  If so, you need to have a different PHP serve it.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 14 July 2006 - 11:46 PM

<tr><font face="Arial, Helvetica, sans-serif" size="2">Picture: <a href="<? echo $picture; ?>">
<? echo $picture; ?>[/url]</font></tr>


<tr><td><font face="Arial, Helvetica, sans-serif" size="2">Picture:</font> <a href="<? echo $picture; ?>">
<img src="<? echo $picture; ?>"></a></td></tr>

You are also missing a few <td>..</td> tags
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users