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? Quote Link to comment 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; } ?> Quote Link to comment 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.