Solved

splitting reult set in pages

Posted on 2004-04-20
3
167 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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
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 count occurrences of each item in an array.

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now