Jump to content

how to display picture from database


checkmodem12

Recommended Posts

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++;
}





?>
   
Link to comment
https://forums.phpfreaks.com/topic/14557-how-to-display-picture-from-database/
Share on other sites

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

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.