johnnyblaze9 Posted April 24, 2008 Share Posted April 24, 2008 I've been trying to retrieve user specific pics from a sql database, and have been given some good advice already, but I can't seem to figure out how to display a picture that I have in a database. When a client logs into my website, I need pictures of his product to be displayed on the page. How do I run a query and then display those results if they are images? Link to comment https://forums.phpfreaks.com/topic/102637-retrieving-pics-from-a-database/ Share on other sites More sharing options...
Fadion Posted April 24, 2008 Share Posted April 24, 2008 Im assuming uve saved in the db the filepath of the images for your users, so getting them shouldnt be difficult. If u need to save several pictures for one client, u can save all of them in one row seperated by a comma (or other characters) or have a different table for the images with a user_id column. A simple scenario: users table ---------- id | username | password photos table ------------ id | path | user_id Where photos.user_id references users.id <?php if($is_logged == true){ //just for example's sake $userID = 10; $resultsPhotos = mysql_query("SELECT path FROM photos WHERE user_id=$userID"); while($valuesPhotos = mysql_fetch_array($resultsPhotos)){ echo "<img src='user_photos/" . $valuesPhotos['path'] . "'"; echo '<br /><br />' } } ?> Hope thats what u needed. Link to comment https://forums.phpfreaks.com/topic/102637-retrieving-pics-from-a-database/#findComment-525650 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.