stav Posted November 30, 2010 Share Posted November 30, 2010 I have this query $sql = "SELECT vid,title,rating FROM video WHERE approved=1 ORDER BY rating DESC LIMIT 10"; and this is the result video page vid | title | rating -------------------------- 1 | title1 | 10 5 | title5 | 12 34 | title34 | 18 6 | title6 | 20 12 | title12 | 20 8 | title8 | 20 54 | title54 | 20 23 | title23 | 43 37 | title37 | 44 3 | title3 | 48 now i have a link in the video result page when user click on video he can see that video in video preview page there i want to ad <<prev and next>> button so user can go to next or prev video from the video resut page if the user watch video vid 12 next will be video with vid 8 and prev the video with vid 6 $nextsql = "SELECT vid,title,rating FROM video WHERE rating >= (SELECT rating from video WHERE vid=12) AND vid!=12 AND approved=1 ORDER BY rating DESC LIMIT 1"; $prevsql = "SELECT vid,title,rating FROM video WHERE rating <= (SELECT rating from video WHERE vid=12) AND vid!=12 AND approved=1 ORDER BY rating ASC LIMIT 1"; but i have problem when there are videos with same rating values Can some one help me to find prev and next vid order by rating in this example Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/220277-prev-next-no-pagination-help/ 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.