matrixx1 Posted April 15, 2011 Share Posted April 15, 2011 I'm creating a funeral home site and on the side of the page I would like to display the last 5 funeral obituaries that are in mySQL database (name and certain sized image (images are in "image" field) w/ a link to an "obituaries detail page for the individual deceased person"). I am able to do this successfully listing only the names....how can I list the image associated with the name? This is what I have so far: <?php include("connect.php"); ?> <?php $query = "SELECT id, deceased_name, deceased_date, DATE_FORMAT(deceased_date, '%M %D, %Y') as datetext"; $query .= " FROM scales_obits ORDER BY deceased_date DESC LIMIT 5"; $listings = mysql_query($query); if (!listings) { echo("<p>Error retrieving listings from lookup table<br>". "Error: " . mysql_error()); exit(); } echo("<table border=\"0\" width=\"100%\" class=\"obit\">"); while ($listing = mysql_fetch_array($listings)) { $deceased_name = $listing["deceased_name"]; $deceased_date = $listing["datetext"]; $id = $listing["id"]; echo("<tr><td width=\"100%\"><a href=\"obitdetail.php?id=".$id."\"><strong>".$deceased_name."</strong></a></td><td> </td>"); } echo("</table>"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/233807-display-images-from-db/ Share on other sites More sharing options...
dcro2 Posted April 15, 2011 Share Posted April 15, 2011 You'll have to select the `image` column from the database as well: $query = "SELECT id, image, deceased_name, deceased_date, DATE_FORMAT(deceased_date, '%M %D, %Y') as datetext"; Then echo it with the other things: $image = $listing["image"]; echo("<tr><td width=\"100%\"><a href=\"obitdetail.php?id=".$id."\"><img src=\"".$image."\" alt=\"".$deceased_name."\"><br><strong>".$deceased_name."</strong></a></td><td> </td>"); Quote Link to comment https://forums.phpfreaks.com/topic/233807-display-images-from-db/#findComment-1202016 Share on other sites More sharing options...
matrixx1 Posted April 15, 2011 Author Share Posted April 15, 2011 THANKS A MILLION!!!....works!!! One last thing...do you know how I can put a white border around the pic? Is that a css solution? Quote Link to comment https://forums.phpfreaks.com/topic/233807-display-images-from-db/#findComment-1202021 Share on other sites More sharing options...
VTJ Posted April 15, 2011 Share Posted April 15, 2011 Yeah the border you can change using css {border:1px #fff solid} Quote Link to comment https://forums.phpfreaks.com/topic/233807-display-images-from-db/#findComment-1202145 Share on other sites More sharing options...
matrixx1 Posted April 15, 2011 Author Share Posted April 15, 2011 Thanks VTJ! Quote Link to comment https://forums.phpfreaks.com/topic/233807-display-images-from-db/#findComment-1202161 Share on other sites More sharing options...
reubencanowski Posted January 4, 2013 Share Posted January 4, 2013 (edited) I'm doing something very similar, but I need to organize my images into seperate tabs based on their date. As it is now, all my tabs show up for all the existing dates but all my images for each specific person retrieved by my query show up on the first tab. So i guess I need them to be sorted by the dates and then inserted into each corrosponding tab. How can I do this? Any help is appreciated. Thanks Edited January 4, 2013 by reubencanowski Quote Link to comment https://forums.phpfreaks.com/topic/233807-display-images-from-db/#findComment-1403262 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.