starvinmarvin14 Posted December 13, 2011 Share Posted December 13, 2011 I have a table in mysql that has the path's of images stored. The image path is stored under the column "photo". The table looks like this: 1 id 2 name 3 age 4 category 5 photo 6 rating I want to create a page such as view.php?id=1 where the image is displayed according to the id. It would have to call upon the path to display it. How would I do this? Link to comment https://forums.phpfreaks.com/topic/253099-display-image-from-mysql/ Share on other sites More sharing options...
The Little Guy Posted December 13, 2011 Share Posted December 13, 2011 An example would be: <?php $id = (int)$_GET['id']; $sql = mysql_query("select * from my_table where id = $id limit 1"); if(mysql_num_rows($sql) > 0){ $row = mysql_fetch_assoc($sql); echo <<<OPT <img src="{$row['photo']}" alt="Image" /> OPT; }else{ header("location: /error.php"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/253099-display-image-from-mysql/#findComment-1297556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.