Page 1 of 1

specific selection from an array, outputting the rest

Posted: Fri Jun 17, 2005 11:43 am
by soianyc
Ok im a bit stuck. I am making a page which displays 4 images. One image is the main image which is large, and the other three are thumbnails. I have a function which dynamically makes thumbnails, so all i have in my database is the location fo the four images. When someone clicks on one of the thumbnails i want that image to become large and the previous image to go into the thumbnails. Here is what i have so far.

Code: Select all

<?php

$picarray = array($row['mainpic'],$row['backpic'],$row['sidepic'],$row['profpic']);

list($mainpic,$backpic, $sidepic, $profpic) = $picarray;

$piccount = count($picarray);


echo '<a href="arraytest.php?menuID='.$menuID.'&itemID='.$itemID.'&picID='.$picID.'"><img src="pix/resize2.php?image='.$picID.'" alt="www.treschicfurs.com" /></a>';

echo '</div>';

echo '<div id="subpic">';
echo '<ul>';


echo '<li class="subpic"><a href="arraytest.php?menuID='.$menuID.'&itemID='.$itemID.'&picID='.$backpic.'"><img src="pix/resize3.php?image='.$backpic.'" /></a></li>';
echo '<li class="subpic"><a href="arraytest.php?menuID='.$menuID.'&itemID='.$itemID.'&picID='.$sidepic.'"><img src="pix/resize3.php?image='.$sidepic.'"  /></a></li>';
echo '<li class="subpic"><a href="arraytest.php?menuID='.$menuID.'&itemID='.$itemID.'&picID='.$profpic.'"><img src="pix/resize3.php?image='.$profpic.'" /></a></li>';


?>

Ive yet to use arrays but this seems to be a good case in using them. Im not to sure what functions i should use here, and how i should setup the loop.

I appreciate all your responses

Regards

-soianyc

Posted: Sat Jun 18, 2005 6:03 am
by dnathe4th
I haven't tested it, but it seemes like you woul dbe able to do this:

Code: Select all

<?php
 
$picarray = array($row['mainpic'],$row['backpic'],$row['sidepic'],$row['profpic']);
 
list($mainpic,$backpic, $sidepic, $profpic) = $picarray;
 
$piccount = count($picarray);
 
 
echo '<a href="arraytest.php?menuID='.$menuID.'&itemID='.$itemID.'&picID='.$picID.'"><img src="pix/resize2.php?image='.$picID.'" alt="www.treschicfurs.com" /></a>';
 
echo '</div>';
 
echo '<div id="subpic">';
echo '<ul>';
 

for($picarray as $pic) {
    if(strcmp($pic, $picID) {
echo '<li class="subpic"><a href="arraytest.php?menuID='.$menuID.'&itemID='.$itemID.'&picID='.$pic.'"><img src="pix/resize3.php?image='.$pic.'" /></a></li>';
};
}
 
?>

Posted: Sat Jun 18, 2005 11:00 am
by soianyc
Sweet, thanks man i had no idea where to go from there.

Regards

-soianyc