Hi Everyone.
I'm an 'advanced' newbie to PHP and I find a lot of things pretty straightforeward. Where I always go wrong are arrays. Either they are really complex or I'm really thick, ... I'll opt for the latter, ...
Anyway, my problem is this:
I have a database with images, each record has 8 fields,
A query is done on a particular aircraft, using the construction number as the key for the query. The results are then put into an array. No problem.
//get the info from the DB
$SQL_p166="SELECT * FROM p166com_img WHERE ac_cons=".$cons;
$p166img_set=mysql_query($SQL_p166);
that works fine.
Now I can dump the data to the screen with this:
while($row=mysql_fetch_array($p166img_set, MYSQL_ASSOC)){
$tmb = $row['img_fil'];
echo "Construction :{$row['ac_cons']} <br>";
echo "<img src=\"tmb/$tmb\"> <br>";
echo "File name : {$row['img_fil']} <br>";
echo "Comments : {$row['img_cmts']} <br>";
echo "Location : {$row['img_loc']} <br>";
echo "Photographer : {$row['img_phot']} <br>";
echo "Date : {$row['img_date']} <br>";
echo "Views : {$row['img_hit']} <br><br>";
}
The result of that would then look like this ....
Construction :452
<image here>
File name : 452-1.jpg
Comments :
Location :
Photographer :
Date :
Views : 0
Fine, so I know that the query works, I know how many images there are of that particular construction number. I am dumping it to the screen just to test, eventually the idea is to display one image, with the rest of the available images for this construction number at thumbs below the main image.
I figure that I need to make an array with a 'sub-array for each field that is returned from the db. So lets say that construction number 417 has 3 pictures I would have to have something like this:
main array(
sub array 1 (cons, image, comments, photographer, date, views, location)
sub array 2 (cons, image, comments, photographer, date, views, location)
sub array 3 (cons, image, comments, photographer, date, views, location)
)
How the heck do I do that in PHP?
maybe I am missing the boat totally, but any help will be appreciated, I'm a bit of a die hard so a nudge in the right direction is more than welcome.
Thanks,
Andrew