Alexhoward Posted January 15, 2009 Share Posted January 15, 2009 Hi guys, Got a bit of a problem, know what i want to do but am stumped on how to do it... think the problem lies in how i've put the data in to the database... Basically i'm using jumploader (a free java multiple image uploader...) to upload images on to my server, and insert the path in to MySQL. It basically runs one at a time, so say you upload 5 images you insert the album name, then choose 5 images, and press upload it then inserts album name, cust_id, Path, and a timestamp into MySQL 5 times I would then like to have a gallery page to view them all by album. so the page is displayed as album name, then 5 sample images underneath, then the next gallery and the next... I can't can't figure out how to pull them out like this grouped by album name... Thanks in advance! Add Some Music http://www.addsomemusic.co.uk Quote Link to comment Share on other sites More sharing options...
flyhoney Posted January 16, 2009 Share Posted January 16, 2009 Honestly, you need a better database schema. But going with the one you have: To get just a list of the album names: SELECT DISTINCT album_name FROM table To get an array of all the images grouped by album names: <?php $images = array(); $query = "SELECT * FROM table"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $images[$row['album_name']][] = $row; } print_r($images); ?> Quote Link to comment Share on other sites More sharing options...
Alexhoward Posted January 16, 2009 Author Share Posted January 16, 2009 Quality! yea, done it like this... <?php $result = mysql_query("SELECT * FROM albums GROUP BY albumname") ; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $aname = $row['albumname'] ; $result2 = mysql_query("SELECT * FROM albums WHERE albumname = '".$aname."' LIMIT 5") ; echo "$aname <br />" ; while($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { $path = $row['path'] ; echo" <img src='$path' height='100' /> "; } echo "<br />" ; } ?> cheers! Add Some Music http://www.addsomemusic.co.uk 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.