PHP Code:
require_once('includes/connection.php')
PHP Code:
require_once('includes/functions.php')
PHP Code:
include('includes/header.php')
PHP Code:
include('includes/sidebar.php')
<h2 id="Intro"><a href="#">Registered Partners</a></h2>
PHP Code:
//Check if there is a page number
if (!(isset($_GET['pagenum'])))
{
$pagenum = 1;
} else {
$pagenum = $_GET['pagenum'];
}
$data = "SELECT * FROM partner";
$result = mysql_query($data, $connection) or die(mysql_error());
//check for number of rows
$rows = mysql_num_rows($result);
//set no. of rows to display per page
$page_rows = 10;
//find last page number
$last = ceil($rows/$page_rows);
//this if statment will see that the page number is exact the max, not 1 below nor 1 above
if ($pagenum < 1)
{
$pagenum =1;
} elseif ($pagenum > $last)
{
$pagenum = $last;
}
$max = 'LIMIT ' .($pagenum - 1) * $page_rows . ',' .$page_rows;
// navigation
$next = $pagenum+1;
$prev = $pagenum-1;
echo " <div class=\"topnav\" align=\"right\"> ";
echo " <div class=\"numbers\"> $pagenum <small>of</small> $last | ";
if($pagenum == 1){
echo "Prev <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next ></a> ";
}
else if ($pagenum == $last) {
echo "<a href='{$_SERVER['PHP_SELF']}?pagenum=$prev'>< Prev</a>   Next";
} else {
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$prev'>< Prev</a> ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next ></a> ";
}
echo "</div></div>";
if ($result) {
//If the Query succeed
print "<br /><table class='partners' border='1' cellpadding='0' cellspacing='0' width='100%'>
<tr>
<th>User</th>
<th>Name</th>
<th>Company</th>
<th>E-mail</th>
<th>Mobile</th>
<th>Edit</th>
</tr>";
$data_p = mysql_query("SELECT * FROM partner $max") or die(mysql_error());
while($info = mysql_fetch_array($data_p)) {
if($i%2 == 0)
{
print "<tr bgcolor='#FFF'>";
$i++;
}
else {
print "<tr bgcolor='#EFF8FF'>";
$i++;
}
print "<td>" . $info['username'] . "</td>";
print "<td>" . ucfirst($info['firstname']) . " " . ucfirst($info['lastname']) . "</td>";
print "<td>" . $info['orgname'] . "</td>";
print "<td>" . $info['email'] . "</td>";
print "<td>" . $info['mobile'] . "</td>";
print "<td><a href='../ipms/edit_partner.php?username={$info['username']}'>Edit</a></td></tr>";
}
print "</table>";
echo " <br /> ";
} else {
//Display error message
echo "<p>Query failed. </p>";
echo mysql_error();
}
Comment