Welcome Guest, Not a member yet? Register   Sign In
Getting a photo of inside an Album for icon
#2

[eluser]JoostV[/eluser]
When you fetch the albums from the database you should be able to grab a single picture from that album as well, in the same query. You should end up with an SQL similar to (from the top of my head)
Code:
$sql = 'SELECT a., p.image MAX(p.date_added) as dateadded FROM albums as a LEFT JOIN photos as p ON (p.albumid = a.id) GROUP BY a.id';

-LEFT JOIN sees to it that you fetch every album, even if there are no photos in it
-GROUP BY a.id sees to it that you fetch only one record per album, assuming that a.id is your unique album id
-MAX(p.date_added) as dateadded sees to it that you fetch the most recent photo


Messages In This Thread
Getting a photo of inside an Album for icon - by El Forum - 12-05-2009, 08:22 AM
Getting a photo of inside an Album for icon - by El Forum - 12-05-2009, 09:37 AM
Getting a photo of inside an Album for icon - by El Forum - 12-05-2009, 09:58 AM
Getting a photo of inside an Album for icon - by El Forum - 12-05-2009, 11:29 AM
Getting a photo of inside an Album for icon - by El Forum - 12-05-2009, 04:13 PM
Getting a photo of inside an Album for icon - by El Forum - 12-05-2009, 04:44 PM
Getting a photo of inside an Album for icon - by El Forum - 12-06-2009, 01:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB