Hi,
To get pagination, you need to do following.
- 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...
- On "Next >>" in HTML page, you may submit value for $start as $start+$count.
- On "<< Prev in HTML page, you may submit value for $start as $start-$count.
- Make sure that $start-$count won't go negative
- Make sure that $start+$count wont go above COUNT(*) of that SQL without limit.
Cheers !
--VC
Updates :
-
Refer MySQL Documentation for syntax of LIMIT in SELECT statement.
-
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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|