Jump to content

Image Gallery Help... if you would be so kind...


Alexhoward

Recommended Posts

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

 

 

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);
?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.