[SOLVED]Almost got it.. pagination (please advice)
Posted: Tue Dec 07, 2004 2:51 pm
Hi All,
I'm a newby with PHP and got a piece of code which I can't get right..
There are no links to next pages created and I can't get it to work although I'v e been reading a lot here.. Please have a look at the code:
Thanks in advance !!
I'm a newby with PHP and got a piece of code which I can't get right..
There are no links to next pages created and I can't get it to work although I'v e been reading a lot here.. Please have a look at the code:
Thanks in advance !!
Code: Select all
<?php
<?php
$maxRows_Comp = 20;
$pageNum_Comp = 0;
if (isset($_GET['pageNum_Comp'])) {
$pageNum_Comp = $_GET['pageNum_Comp'];
}
$startRow_Comp = $pageNum_Comp * $maxRows_Comp;
?>
<font size="+4" color="#CCCCCC"<strong>Competitie standen ASN 2005</strong></font>
<?php
/* Connecting, selecting database */
$link = mysql_connect("XXX", "xxxx", "xxxx")
or die("Could not connect : " . mysql_error());
mysql_select_db("ASN") or die("Could not select database");
$query_Comp = "SELECT
`klasse`.`Klasse` AS `Klasse`,
`klassement`.`LevelId` AS `Level`,
`deelnemer`.`Naam` AS `naam`,
`deelnemer`.`Vereniging` AS `Vereniging`,
TRUNCATE (`klassement`.`Totaal percentage` * 100, 2) AS `Totaal%`,
TRUNCATE (`klassement`.`Gemiddelde percentage` * 100,2) AS `Gem%`
FROM
`klassement`
INNER JOIN `deelnemer` ON (`klassement`.`DeelnemerId` = `deelnemer`.`Id`)
INNER JOIN `deelnemerklasselevel` ON (`deelnemer`.`Id` = `deelnemerklasselevel`.`DeelnemerId`)
INNER JOIN `klasse` ON (`klassement`.`KlassId` = `klasse`.`Id`)
GROUP BY `Klasse`,`Naam`,`Level`
ORDER BY `Klasse`,`Level`,`Totaal Percentage` DESC";
$query_limit_Comp = sprintf("%s LIMIT %d, %d", $query_Comp, $startRow_Comp, $maxRows_Comp);
$Comp = mysql_query($query_limit_Comp, $link) or die(mysql_error());
$row_Comp = mysql_fetch_assoc($Comp);
if (isset($_GET['totalRows_Comp'])) {
$totalRows_Comp = $_GET['totalRows_Comp'];
} else {
$all_Comp = mysql_query($query_Comp);
$totalRows_Comp = mysql_num_rows($all_Comp);
}
$totalPages_Comp = ceil($totalRows_Comp/$maxRows_Comp)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>ASN Competitie</title>
<style type="text/css">
<!--
.style3 {
font-size: 14pt;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table width="61%" border="1">
<tr>
<td width="7%"><span class="style3">Klasse</span></td>
<td width="7%"><strong class="style3">Level</strong></td>
<td width="17%"><strong class="style3">Naam</strong></td>
<td width="22%"><strong class="style3">Vereniging</strong></td>
<td width="14%"><strong class="style3">Totaal %</strong></td>
<td width="11%"><strong class="style3">Gem % </strong></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo ucfirst($row_Comp['Klasse']); ?></td>
<td><?php echo htmlentities($row_Comp['Level']); ?></td>
<td><?php echo ucfirst($row_Comp['naam']); ?></td>
<td><?php echo htmlentities($row_Comp['Vereniging']); ?></td>
<td><?php echo $row_Comp['Totaal%']; ?></td>
<td><?php echo $row_Comp['Gem%']; ?></td>
</tr>
<?php } while ($row_Comp = mysql_fetch_assoc($Comp)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Comp);
?>
?>