Solved

splitting reult set in pages

Posted on 2004-04-20
3
170 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

803 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