The Little Guy Posted July 20, 2007 Share Posted July 20, 2007 OK... I use this PHP code to make my javascript array (this works): <?php $imgSQL = mysqli_query($db,"SELECT * FROM friends_images WHERE ownerID = '$id'"); $i = 0; $imgCount = mysqli_num_rows($imgSQL); echo 'var imagesArray = new Array('.$imgCount.');'."\n"; while($imgROW = mysqli_fetch_array($imgSQL)){ echo 'imagesArray['.$i.'] = "'.$imgROW['id'].'";'."\n"; $i++; } ?> I use this to go create a forward / backwards button (this doesn't work): function rotateImage(dir,imageID){ for (i=0;i<imagesArray.length;i++){ if(imagesArray[i] == imageID){ var currlo = imagesArray[i]; if(i++ == imagesArray.length){ var next = imagesArray[0]; }else{ var next = imagesArray[i++]; } if(i == 0){ var prev = imagesArray[imagesArray.length]; }else{ var prev = imagesArray[i--]; } } } document.getElementById('left').href = 'javascript:rotateImage(\'left\',\''+prev+'\');'; document.getElementById('right').href = 'javascript:rotateImage(\'right\',\''+next+'\');'; } How can I make forward / backwards buttons from the array that was created? I don't really know what this is doing, so don't ask, I know how it "should" work, but it isn't doing that. Anyone know how to make this better? Link to comment https://forums.phpfreaks.com/topic/60980-solved-forward-backward-buttons/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.