checkmodem12 Posted July 14, 2006 Share Posted July 14, 2006 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? <?$username="";$password="";$database="";mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");$query="SELECT * FROM test_mysql WHERE classification='crafts'";$result=mysql_query($query);$num=mysql_numrows($result);mysql_close();$i=0;while ($i < $num) {$id=mysql_result($result,$i,"id");$description=mysql_result($result,$i,"description");$price=mysql_result($result,$i,"price");$picture=mysql_result($result,$i,"picture");$classification=mysql_result($result,$i,"classification");?><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><?$i++;}?> Quote Link to comment https://forums.phpfreaks.com/topic/14557-how-to-display-picture-from-database/ Share on other sites More sharing options...
fenway Posted July 14, 2006 Share Posted July 14, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/14557-how-to-display-picture-from-database/#findComment-57780 Share on other sites More sharing options...
Barand Posted July 14, 2006 Share Posted July 14, 2006 Change[code]<tr><font face="Arial, Helvetica, sans-serif" size="2">Picture: <a href="<? echo $picture; ?>"><? echo $picture; ?>[/url]</font></tr>[/code]to[code]<tr><td><font face="Arial, Helvetica, sans-serif" size="2">Picture:</font> <a href="<? echo $picture; ?>"><img src="<? echo $picture; ?>"></a></td></tr>[/code]You are also missing a few <td>..</td> tags Quote Link to comment https://forums.phpfreaks.com/topic/14557-how-to-display-picture-from-database/#findComment-58184 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.