Schlo_50 Posted January 14, 2007 Share Posted January 14, 2007 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 More sharing options...
wildteen88 Posted January 14, 2007 Share Posted January 14, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.