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
Solved

splitting reult set in pages

Posted on 2004-04-20
3
171 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

808 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