Ok, I know this is really simple and I'm just, again, stuck on something dumb.
The basic gist is that I have 3 tables in the database - galleries, photos, gallery_content.
table "galleries" - has gallery_id, gallery (gallery name), directory (where image is stored) and display (orientation - horz=horizontal / vert=vertical)
"photos" has the image info - name, thubnail name, caption etc...
"gallery_content" - tells what images are in each gallery
totally simple, the application is actually done and working fine minus some alignment and tweaking.
the thing is -- i want to store a simple array of gallery info - just gallery_id and name so i can pass gallery_id as $g on the url but stil easily access the name of the gallery.
in a previous application, i did something like this:
if (! isset($stateData) ) session_register ("stateData");
//LOOP THROUGH DB RESULTS:
$q="select * from states";
$r=mysql_query($q);
while ($a=mysql_fetch_array){
$stateData[$a['state_abbr']]['name']=$a['state_name'];
$stateData[$a['state_abbr']]['population']=$a['population'];
}
I could then get the info by saying something like:
$abbrIn="MN";
echo "$stateData[$abbrIn]['population']";
to print the population...
That works fine BUT I'm trying to be a good girl and use $_SESSION instead...
I think this should be rather simple but I'm unable to either load or access the information.
I first tried something like this:
$q_galleries="select * from galleries";
$r_galleries=mysql_query($q_galleries);
while ($a_galleries=mysql_fetch_array($r_galleries)) {
$g=$a_galleries['gallery_id'];
$g_name=$a_galleries['gallery'];
$g_display=$a_galleries['display'];
$_SESSION['gallery_data'][$g]['g']=$g;
$_SESSION['gallery_data'][$g]['name']=$g_name;
$_SESSION['gallery_data'][$g]['display']=$g_display;
}//end while
but print_r($_SESSION) gave me wacky results like...
Array ( [gallery_data] => Array ( [g] => h3 [1] => h [18] => h8 [16] => h6 [20] => h0 [19] => h9 [21] => h1 [23] => h3 ) [] => horz [$gallery_data] => Array ( [g] => ) )
I have this feeling that it's getting in ok, I'm just having problems getting it out.
This seems to work...
while ($a_galleries=mysql_fetch_array($r_galleries)) {
$g=$a_galleries['gallery_id'];
$g_name=$a_galleries['gallery'];
$g_display=$a_galleries['display'];
$_SESSION['gallery_data'][$g]=$g;
$_SESSION[$g]['name']=$g_name;
$_SESSION[$g]['display']=$g_display;
}//end while
The print_r gets all the data out but I would rather have it in 1 array with the key being the gallery id.
Not to mention, I'm unable to get the data out in any other form. I've tried several different loops.
I should be able to just count the number of elements in the $gallery_data array, loop through it and grab the info using something like this: $gallery_data[$g]['name'] With the above I would need to have a loop w/in the loop.
Any help, examples, input would be greatly appreciated! My head hurts. :bemused: