Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: DB Search

by atemon (Chaplain)
on Aug 08, 2007 at 10:45 UTC ( [id://631276]=note: print w/replies, xml ) Need Help??


in reply to DB Search

Hi,

To get pagination, you need to do following.

  1. Format your SQL as something like $SQL = "SELECT * FROM xyz ..... LIMIT $start, $count". Where $start is the count to start with and $count is No of records to be displayed. 0,10 will display 1st 10 records, 10,10 gives items 10 to 19 etc...
  2. On "Next >>" in HTML page, you may submit value for $start as $start+$count.
  3. On "<< Prev in HTML page, you may submit value for $start as $start-$count.
  4. Make sure that $start-$count won't go negative
  5. Make sure that $start+$count wont go above COUNT(*) of that SQL without limit.

Cheers !

--VC

Updates :

  1. Refer MySQL Documentation for syntax of  LIMIT in SELECT statement.
  2. Have a look at PerlMonks FAQ, The Perl Monks Guide to the Monastery for more information on how the Monastery works. How (Not) To Ask A Question will be a good guide. There are hundreds of thousands of posts here, Super Search is your friend. There are more than one postings available in the monastery regarding pagination



There are three sides to any argument.....
your side, my side and the right side.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://631276]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 17:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found