Solved

splitting reult set in pages

Posted on 2004-04-20
3
173 Views
Last Modified: 2008-03-04
how can i split result set in pages so that i can do navigation like next and previous
0
Comment
Question by:abhishek2002
3 Comments
 
LVL 6

Accepted Solution

by:
jkna_gunn earned 125 total points
ID: 10876048
you have to add LIMIT function to your mysql queries.

there is another question on this forum recently that asked to do something similar.

$query = "select * from mytable LIMIT 0,10";

that would select first 10 records.

so if you made a variable $limit and a constant $resultsperpage = 10;

you could do this

$query = "select * from mytable LIMIT $limit,$resultsperpage";

to make next and previous work you will need to pass parameters to the page, for this example you would just pass the page number.

so on the first page your next link would be like this :
<a href="results.php?page=2">Next</a>

you can then work out the limt from the page number :
$page = $_GET["page"];
$limit = ($page - 1) * $resultsperpage;

hope that gives you an understanding
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP Mail error 3 43
Add a loading gif while php runs server side 15 64
Reference key in foreach loop 4 38
PHP Curl Problem 10 35
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question