my suggestion would to create a javascript array that takes care of an array of images and using a little more javascript to take care of the forward and back buttons.
I have done this with single images but it shouldn't be to much trouble to modify it to use five images at a time..
Code: Select all
$sql="SELECT picName, picId FROM picture WHERE clientNbr=$clientId AND picId='pg'";
$db->Exec_Sql($sql);
$n=$db->Row_Count();
$myPix=" myPix=new Array(";
for($y=0; $y<$n; $y++)
{
$row=$db->Next_Record();
$src=$rowї'picName'];
$myPix.=""$src"";
if($y<$n-1)
$myPix.=",";
}
$myPix.=");\n";
I have my image names stored in db but you should get the idea of what I am doing.
the $myPix variable is being concatinated together to create a javascript array that I echo out inbetween my <script> tags and use the following js goop to process the picture
Code: Select all
function processPic(n)
{
oldPic=document.gallery.src
thisPic+=n;
//alert("thisPic is "+thisPic+" myPixLength is "+myPix.length);
if(thisPic >= 0 && thisPic < myPix.length)
{
document.gallery.src=path+myPixїthisPic];
//alert(document.gallery.src);
}
else
{
document.gallery.src=oldPic;
thisPic-=n;
}
if(thisPic >= myPix.length-1)
{
document.next1.src="images/backgroung.gif";
document.next2.src="images/backgroung.gif";
}
else
{
document.next1.src="images/gallery_next_g.gif";
document.next2.src="images/gallery_next_g.gif";
}
if(thisPic <= 0)
{
document.prev1.src="images/backgroung.gif";
document.prev2.src="images/backgroung.gif";
}
else
{
document.prev1.src="images/gallery_prev_g.gif"
document.prev2.src="images/gallery_prev_g.gif";;
}
}
Im sure it could be more elegant but it works.
It takes care of diplaying previous and next buttons and displays a default pic if there is no prev or next.
here is an example of the href around the image.
Code: Select all
<A HREF="javascript:processPic(1)">
<img src='images/gallery_next_g.gif' border='0' hspace='0' vspace='0' name="next2"></A>
I just pass in wether to 1 or -1 as the parameter. I don't see why it won't work for doing five pics at a time. You will have to modify the code so thaty you are changing all five pics but that shouldn't be to much effor either.
need more help just post agian