Jump to content

Pagination


jerastraub

Recommended Posts

I see... so every page your going to display 9 rows only?

 

<?
include("connDB.php");	

$Limit = 9; //Number of results per page

$SearchString=$_POST["lotId"]; // Get the search tearm

If($SearchString == "") $SearchString=$_GET["SearchString"]; // Get the search tearm

$page=$_GET["page"]; //Get the page number to show
If($page == "") $page=1; //If no page number is set, the default page is 1

//Get the number of results
$SearchResult=mysql_query("SELECT * FROM phase ORDER BY lotNum") or die(mysql_error());
$NumberOfResults=mysql_num_rows($SearchResult);

//Get the number of pages
$NumberOfPages=ceil($NumberOfResults/$Limit);
$SearchResult=mysql_query("SELECT * FROM phase ORDER BY lotNum LIMIT " . ($page-1)*$Limit . ",$Limit") or die(mysql_error());
While($row = mysql_fetch_object($SearchResult)) {
$x = $x + 1;
if ($x % 2 != 0)
{
	$x = $x + 1;
                  Echo $row->lotBlock . "<BR>";
                  Echo $row->lotNum . "<BR>";
}
}

$Nav="";
If($page > 1) {
$Nav .= "<A HREF=\"phase2.php?page=" . ($page-1) . "\"><<</A>";
}else{
//$Nav .= " << ";
}
For($i = 1 ; $i <= $NumberOfPages ; $i++) {
If($i == $page) {
$Nav .= "<B>$i</B>";
}Else{
$Nav .= "<A HREF=\"phase2.php?page=" . $i ."\"> $i </A>";
}
}
If($page < $NumberOfPages) {
$Nav .= "<A HREF=\"phase2.php?page=" . ($page+1) .  "\">>></A>";
}else{
//$Nav .= " >> ";
}
Echo "" . $Nav;
?>

Link to comment
https://forums.phpfreaks.com/topic/91215-pagination/#findComment-467500
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.