View Full Version : Limit number of records being pulled in from database.

01-28-2010, 01:09 PM
Is there a way to limit the number of rows to pull in and display from a database?

And then, add a link to display another page with more posts. Preferably on the same.

My theory:

while $i < 5 "get results";

if (isset($_POST['nxtPage'])) {
displayMore posts, from 5 - 10
if (isset($_POST['prvPage'])) {
displaypreview posts

<form><input type="submit" name="prvPage"><input type="submit" name="nxtPage"></form>

Just a rough idea ^ (Code not intended to be accurate Lol)

01-28-2010, 01:15 PM
use GET vars with pagination and a LIMIT on the mysql query?

01-28-2010, 03:09 PM
As Jay says, Pagination is how you automatically add pages per number of rows.

A LIMIT works like this,

mysql_query("SELECT firstname FROM users WHERE id='$id' LIMIT 3");

So if you had 5 records, it'd only show 3.