snowboardr
Programmer
It appears my php code is returning the amount of records in every table in the db and im not sure why... this is thus throwing off the paging count...
paging numbers/next/prev etc..
Jason
[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]
Code:
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Customers = 10;
$pageNum_Customers = 0;
if (isset($_GET['pageNum_Customers'])) {
$pageNum_Customers = $_GET['pageNum_Customers'];
}
$startRow_Customers = $pageNum_Customers * $maxRows_Customers;
mysql_select_db($database_mysql, $mysql);
$query_Customers = "SELECT * FROM customers ORDER BY clast ";
$query_limit_Customers = sprintf("%s LIMIT %d, %d", $query_Customers, $startRow_Customers, $maxRows_Customers);
$Customers = mysql_query($query_limit_Customers, $mysql) or die(mysql_error());
$row_Customers = mysql_fetch_assoc($Customers);
if (isset($_GET['totalRows_Customers'])) {
$totalRows_Customers = $_GET['totalRows_Customers'];
} else {
$all_Customers = mysql_query($query_Customers);
$totalRows_Customers = mysql_num_rows($all_Customers);
}
$totalPages_Customers = ceil($totalRows_Customers/$maxRows_Customers)-1;
$queryString_Customers = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Customers") == false &&
stristr($param, "totalRows_Customers") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Customers = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Customers = sprintf("&totalRows_Customers=%d%s", $totalRows_Customers, $queryString_Customers);
?>
paging numbers/next/prev etc..
Code:
<table border="0" align="center" class="ttable" style="margin-top:5px; margin-bottom:5px;">
<tr>
<?php if ($pageNum_Customers > 0) { // Show if not first page ?>
<td>
<a class="dl" href="<?php printf("%s?pageNum_Customers=%d%s", $currentPage, 0, $queryString_Customers); ?>">First</a>
</td><?php } // Show if not first page ?>
<?php if ($pageNum_Customers > 0) { // Show if not first page ?>
<td>
<a class="dl" href="<?php printf("%s?pageNum_Customers=%d%s", $currentPage, max(0, $pageNum_Customers - 1), $queryString_Customers); ?>">Previous</a>
</td> <?php } // Show if not first page ?> <?php if ($pageNum_Customers < $totalPages_Customers) { // Show if not last page ?>
<?php if($totalPages_Customers > 1) {?>
<td style="padding-right:3px;">
<?php
for ($pg=1; $pg<$totalPages_Customers+2; $pg+=1) {
if ($pg>$totalPages_Customers) {break;}
if (!($pageNum_Customers==0 && $pg==1)) {
if (!($pageNum_Customers==$pg)) {
echo "<a class='dl' title='View page ".$pg."' href='index.php?pageNum_Customers=".$pg."&totalRows_Customers=".$totalRows_Customers."'>".$pg."</a> ";
} else {
echo "<a class='dl2' title='View page ".$pg."' href='index.php?pageNum_Customers=".$pg."&totalRows_Customers=".$totalRows_Customers."'>".$pg."</a> ";
}
} else {
echo "<a class='dl2' title='View page ".$pg."' href='index.php?pageNum_Customers=".$pg."&totalRows_Customers=".$totalRows_Customers."'>".$pg."</a> ";
}
}
?>
</td> <?php } // page numbers ?>
<td>
<a class="dl" href="<?php printf("%s?pageNum_Customers=%d%s", $currentPage, min($totalPages_Customers, $pageNum_Customers + 1), $queryString_Customers); ?>">Next</a>
</td> <?php } // Show if not last page ?>
<?php if ($pageNum_Customers < $totalPages_Customers) { // Show if not last page ?><td>
<a class="dl" href="<?php printf("%s?pageNum_Customers=%d%s", $currentPage, $totalPages_Customers, $queryString_Customers); ?>">Last</a>
</td> <?php } // Show if not last page ?>
</tr>
</table>
Jason
[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]