rondog Posted September 28, 2007 Share Posted September 28, 2007 I have a big video library in my database. I have a video.php that displays whatever you video you clicked on from the list. On the video page I've made a previous and next link with a thumbnail of the previous and next videos. That was the easy part. The part I am having trouble with is if you are on the very first video, you are still able to click the link, except it breaks since there is nothing left. The same goes for the next button. I just want the previous link to be inactive if its on the first one and the next button to be inactive if you're on the last one. I was thinking of just using mysql_num_rows which gets me the total videos for that particular camera/tape, but I cant think of any logic that could work with that. I cant use the videos ID since camera B, Tape 1, video 1 isnt at row 1..It comes after all of camera A Tape1 - 9. Here is what I am doing right now. Maybe you guys can think of something better? That first block of php is just to get the next and previous images and links. Im trying to fix the prev and next problem right below that. <?php $current = $row[0]; $prev = $current - 1; $next = $current + 1; $getprev = mysql_query("SELECT vidname FROM videos WHERE id = '$prev'"); $prevrow = mysql_fetch_row($getprev); $prevflv = $prevrow[0]; $previmg = str_replace(".flv",".jpg","$prevflv"); $checkprev = "cam_$c_loc/tape_$t_loc/imgs/$previmg"; $prevrplc = str_replace(".flv","","$prevflv"); $getnext = mysql_query("SELECT vidname FROM videos WHERE id = '$next'"); $nextrow = mysql_fetch_row($getnext); $nextflv = $nextrow[0]; $nextimg = str_replace(".flv",".jpg","$nextflv"); $checknext = "cam_$c_loc/tape_$t_loc/imgs/$nextimg"; $nextrplc = str_replace(".flv","","$nextflv"); //fix end and beginning link issues $numVids = mysql_query("SELECT id FROM videos WHERE tape = 'tape_$t_loc' AND camera = 'cam_$c_loc'"); $numvidcount = mysql_num_rows($numVids); echo $numvidcount;//113 ?> <table width="0" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td> <?php if(file_exists($checkprev)) { echo("<a href=\"video.php?vid=cam_$c_loc/tape_$t_loc/$prevrplc&cam=$c_loc&tape=$t_loc\" target=\"_self\"><img src=\"cam_$c_loc/tape_$t_loc/imgs/$previmg\" width=\"100\" height=\"100\" alt=\"$previmg\" border=\"0\" /></a>"); } else { echo("<a href=\"video.php?vid=cam_$c_loc/tape_$t_loc/$prevrplc&cam=$c_loc&tape=$t_loc\" target=\"_self\"><img src=\"nopic.jpg\" width=\"100\" height=\"100\" alt=\"$previmg\" border=\"0\" /></a>"); } ?> </td> <td> <?php if( if(file_exists($checknext)) { echo("<a href=\"video.php?vid=cam_$c_loc/tape_$t_loc/$nextrplc&cam=$c_loc&tape=$t_loc\" target=\"_self\"><img src=\"cam_$c_loc/tape_$t_loc/imgs/$nextimg\" width=\"100\" height=\"100\" alt=\"$nextimg\" border=\"0\" /></a>"); } else { echo("<a href=\"video.php?vid=cam_$c_loc/tape_$t_loc/$nextrplc&cam=$c_loc&tape=$t_loc\" target=\"_self\"><img src=\"nopic.jpg\" width=\"100\" height=\"100\" alt=\"$nextimg\" border=\"0\" /></a>"); } ?> </td> </tr> <tr> <td><?php echo("<a href=\"video.php?vid=cam_$c_loc/tape_$t_loc/$prevrplc&cam=$c_loc&tape=$t_loc\" target=\"_self\"><div align=\"right\"><span class=\"prevnext\">« Prev</span></div></a>"); ?></td> <td><?php echo("<a href=\"video.php?vid=cam_$c_loc/tape_$t_loc/$nextrplc&cam=$c_loc&tape=$t_loc\" target=\"_self\"><span class=\"prevnext\">Next »</span></a>"); ?></td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/71087-solved-help-with-previous-and-next-button-in-gallery/ Share on other sites More sharing options...
sKunKbad Posted September 28, 2007 Share Posted September 28, 2007 I think what you are trying to do is called "pagination", and you should find endless tutorials online regarding the subject. Quote Link to comment https://forums.phpfreaks.com/topic/71087-solved-help-with-previous-and-next-button-in-gallery/#findComment-357481 Share on other sites More sharing options...
rondog Posted September 28, 2007 Author Share Posted September 28, 2007 No, I know what that is. Ive figured it out I just need to know how you find out what row you are currently on. How would I do that? Quote Link to comment https://forums.phpfreaks.com/topic/71087-solved-help-with-previous-and-next-button-in-gallery/#findComment-357521 Share on other sites More sharing options...
rondog Posted September 28, 2007 Author Share Posted September 28, 2007 nevermind I got it Quote Link to comment https://forums.phpfreaks.com/topic/71087-solved-help-with-previous-and-next-button-in-gallery/#findComment-357540 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.