I'm working on a project where I have a table album_image that has the id numbers from two other tables (album and image). What I'm looking to do is set up an array because it seems the only logical way to do it. The table looks something like
album_id- 1 image_id-2
album_id-1 image_id-8
album_id-2 image_id 20
album_id-2 image_id 1
album_id-2 image_id 5
...which basically comes down to a one to many relationship. What I want to do is connect to MySQL, get the information, put it into an array where $array[$album_id][columns]=$image_id. So my array basically be a row of $album_id, and an undefined number of columns [based on the number of $image_id]. I haven't made any declarations on the array until what I show here. This is what I have, but it doesn't work (my query works fine):
while ($row = mysql_fetch_array($result))
{
$album_id = $row['album_id'];
$image_id = $row['image_id'];
$array[$album_id][]=$image_id;
}
//get the album information
for ($col=1; $col<$album_id; $col++)
{
for ($ro=1; $ro<$i; $ro++)
{
echo "$array[$col][$ro]";
}
}
I'm basically trying to create links on page and post the $image_ids to the next page to display an album.
Thanks any help!!!!