Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slideshow Script

Status
Not open for further replies.

bentleykf

Programmer
Apr 29, 2002
59
AU
I have this little slide show script but it doesn't seem to work. I think it's a problem with the if statements because each time the script is reloaded the if statements are run even if they aren't true. What's the problem with this?

---------------------------------
if ($pid=$nid) {
$ppid="--$pid";
$npid="++$pid";
printf (&quot;<a href= onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('previous','',' name=previous border=0 src= width=16 height=17 align=absmiddle></a><img name=next border=0 src= width=16 height=17 align=absmiddle>&quot;, $mid, $ppid, $nid);
} else {
if ($pid = &quot;1&quot;) {
$npid=2;
printf (&quot;<img name=previous border=0 src= width=16 height=17 align=absmiddle><a href= onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('next','',' name=next border=0 src= width=16 height=17 align=absmiddle></a>&quot;, $mid, $npid, $nid);
} else {
$ppid=&quot;--$pid&quot;;
$npid=&quot;++$pid&quot;;
printf (&quot;<a href= onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('previous','',' name=previous border=0 src= width=16 height=17 align=absmiddle></a><a href= onMouseOut=MM_swapImgRestore() onMouseOver=MM_swapImage('next','',' name=next border=0 src= width=16 height=17 align=absmiddle></a>&quot;, $mid, $ppid, $nid, $mid, $npid, $nid);
}
}
 
Heres a simple prev/next and image display script, works fine, you'll just need to add your mousovers and possibly change the source of the images.

<?php
// determine if we have a start number , esle we start at 1
if(!isset($pic_id)){
$pic_id=1;
}
// set total number of images here
$max_pics=10;

// work out next and last image numbers
$next=($pic_id+1);
$prev=($pic_id-1);

// if we are at 1 , last is $max_pics
if($pic_id==1){
echo &quot;pic $pic_id<img scr=_images/$pic_id.jpg><br>&quot;;
echo &quot;<a href=$PHP_SELF?pic_id=$max_pics>prev</a>&nbsp<a href=$PHP_SELF?pic_id=$next>next</a>&quot;;

}else{

// we are no longer at 1 , we need to loop bak to 1 if we are at $max_pics
if($pic_id==$max_pics){
echo &quot;pic $pic_id<img scr=_images/$pic_id.jpg><br>&quot;;
echo &quot;<a href=$PHP_SELF?pic_id=$prev>prev</a>&nbsp<a href=$PHP_SELF?pic_id=1>next</a>&quot;;

}else{
// doing this as we arent at 1 or at $max_pics
echo &quot;pic $pic_id<img scr=_images/$pic_id.jpg><br>&quot;;
echo &quot;<a href=$PHP_SELF?pic_id=$prev>prev</a>&nbsp<a href=$PHP_SELF?pic_id=$next>next</a>&quot;;
}
}


?>
***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top