Maybe this'll help someone understand more what I'm asking. I made it this far... here's the code:
$result = db_query("
SELECT f.filename, f.thumbname, f.section, f.description, s.SEC_ID
FROM chant_files AS f
LEFT JOIN chant_sections AS s ON f.section = s.SEC_ID", __FILE__, __LINE__);
print "<pre>";
$list['sections'] = array();
while ($row = mysql_fetch_assoc($result))
{
$list['sections'][$row['SEC_ID']] = array(
'id' => $row['SEC_ID'],
'files' => array(),
);
$$list['sections'][$row['SEC_ID']][$row['files']] = array(
'name' => $row['filename'],
'section' => $row['section'],
'description' => $row['description'],
'link' => '<a href="' . $imageurl . $row['filename'] .'">' . $row['filename'] . '</a>'
);
}
print_r($list);
print "</pre>";
And here's the outputted array format:
Array
(
[sections] => Array
(
[images] => Array
(
[id] => images
[files] => Array
(
)
)
[peter] => Array
(
[id] => peter
[files] => Array
(
)
And here's what's actually in the tables:
Array
(
[filename] => kitty
[thumbname] =>
[section] => images
[description] => free cat
[SEC_ID] => images
)
Array
(
[filename] => freecat.jpg
[thumbname] =>
[section] => images
[description] => free cat
[SEC_ID] => images
)
Array
(
[filename] => butterfly1.jpg
[thumbname] =>
[section] => images
[description] => a pretty butteryfly
[SEC_ID] => images
)
Array
(
[filename] => powered-php.gif
[thumbname] =>
[section] => images
[description] => afsdfadfasfds
[SEC_ID] => images
)
Array
(
[filename] => DogAssailant.jpg
[thumbname] =>
[section] => peter
[description] => watch your dogs
[SEC_ID] => peter
)
Keeping in mind that SEC_ID is joined from it's own table. So what I'm trying to first echo the section name and then echo all the files in that section, then move onto the next section, echo files, ect, ect. I need it in a foreach loop I think because there's not defined number of sections. It could be one or a hundred. Same goes with files. This help anyone out in helping me?
Thanks again,
Metho