Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/220277-prev-next-no-pagination-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.