lets say I have a mysql database with a table containing 100+ rows. If I only want to display 20 enteries at a time on a page, how would i do so?
thanks
Dimava
thanks
Dimava
Welcome to the vBulletin support forums! In our community forums you can receive professional support and assistance with any issues you might have with your vBulletin Products.
Useful Links for Guests:
If you are having problems posting in the relevant areas for your software, please see this topic.
class pages {
var $content;
function pages($table,$limit,$page) {
$mysql = new mysql();
$result = $mysql->query("SELECT * FROM `$table`");
$numrows = mysql_num_rows($mysql->query);
$mysql->close();
if (ereg("\\?",$page)) {
$page .= "&";
} else {
$page .= "?";
}
if (!$_GET[offset]) {
$offset = 0;
} else {
$offset = $_GET[offset];
}
if ($offset) {
$prevoffset = $offset - $limit;
$content .= " [<A href=\"$page" . "offset=$prevoffset\">Prev</A>] ";
}
$pages = intval($numrows / $limit);
if ($numrows % $limit) {
$pages++;
}
for ($x = 1; $x <= $pages; $x++) {
$newoffset = $limit * ($x - 1);
if($newoffset == $offset) {
$content .= " [$x] ";
} else {
$content .= " [<A href=\"$page" . "offset=$newoffset\">$x</A>] ";
}
}
if(($pages == 1) || (($offset / $limit) == $pages) || (($offset / $limit) == ($pages - 1))) {
} else if (!(($offset / $limit) == $pages) && $pages != 1) {
$newoffset = $offset + $limit;
$content .= " [<A href=\"$page" . "offset=$newoffset\">Next</A>] ";
}
$this->content = "<DIV align=\"center\">$content</DIV>\n";
}
}
Comment