Grab the RSS feed

Pagination like facebook message inbox

Hi friends,

Today I faced a situation like making the pagination depending upon particular id.

For example in my situation the user in message inbox with detail view.There is button for Previous and Next in detail view.But I listed out the Friend Request only in the inbox.But there is also an criteria for ordinary message.So if the user in the Friend request view I need to filter out the Next message for the 'Friend Request'.

The Friend Request query is

SELECT * FROM tbl_message Where SUBJECT='Friend Request' and Contactid='myid';
It returns
messageid     Message           Subject              contactidfrom
---------------------------------------------------------------

1                                Hi                          Friend Request        Friendid

10                             Hi              Friend Request        Friendid

15                             Hi                             Friend Request         Friendid

In that situation if the user click the messageid 10 and if he is watching the message there is display for next and previous button.

If he clicks the previous button then I need to 'messageid' 1 and if clicks the Next button I need to redirect user to 'messageid' 15.For that we can make it simple.

Write the query like below.

This is for the 'Next' button
SELECT * FROM tbl_message Where SUBJECT='Friend Request'AND messageid > 'currentid'
 AND Contactid='myid';
For 'Previous' button
SELECT * FROM tbl_message Where SUBJECT='Friend Request' AND messageid < 'currentid'
 AND Contactid='myid';

Current id here goes to 10

Please leave the comment to improve us....

0 comments:

  •  
    Real Time Web Analytics