...

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



martynball
01-28-2010, 12: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";

displayResults
$i++
}
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)

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

masterofollies
01-28-2010, 02: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum