Jump to content

Recommended Posts

Here is a script i have created so that i can display information from my MySQL database. I would like to be able to display an image on the page too. I have diverted from storing the image as a BLOB on the db and have decided intead, to store the image URL. I have done this but now all that happens when i load the script is the URL is displayed in text form. I know i need to add <img src somewhere, but where and how?  ???

[quote]
<?
$host = 'correct' ;
$user = 'correct' ;
$pass = 'correct' ;
$db = 'correct' ;
$table = 'correct' ;
$show_all = 'SELECT * FROM correct' ;

mysql_connect ($host,$user,$pass) or die ( mysql_error ());
mysql_select_db ($db)or die ( mysql_error ());
$result = mysql_query ($show_all) or die ( mysql_error ());
while ($row = mysql_fetch_array ($result))
echo $row['name']. " - ". $row['image'].$row['descr']. " - ". $row['price'];
echo "<br />";

?>
[/quote]

Thanks for your help!
Link to comment
https://forums.phpfreaks.com/topic/34115-image-display-mysql/
Share on other sites

Change this:
[code]while ($row = mysql_fetch_array ($result))
echo $row['name']. " - ". $row['image'].$row['descr']. " - ". $row['price'];
  echo "
";[/code]

To this:
[code=php:0]while ($row = mysql_fetch_array ($result))
{
    echo $row['name']. ' - <img src="'. $row['image'] . '" />' . $row['descr'] . ' - ' . $row['price'] . "<br />\n";
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/34115-image-display-mysql/#findComment-160437
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.