Solved

splitting reult set in pages

Posted on 2004-04-20
3
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
curl parse data from site 20 66
assigning javascript variable to php variable 8 69
Export Data from MySql Using PHP 16 67
geting data from the array list 6 37
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

739 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