Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_cache_limiter();
- session_start();
- require('config.php');
- require('functions.php');
- //check for administrative rights
- if (allow_access(Administrators) != "yes")
- {
- include ('no_access.html');
- exit;
- }
- //counts rows in table
- $sql = "SELECT COUNT(*) FROM clients";
- $result = mysql_query($sql, $conn) or die(mysql_error());
- echo mysql_error();
- $r = mysql_fetch_row($result);
- $numrows = $r[0];
- //rows per page
- $rowsperpage = 15;
- // find out total pages
- $totalpages = ceil($numrows / $rowsperpage);
- // get the current page or set a default
- if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
- // cast var as int
- $currentpage = (int) $_GET['currentpage'];
- } else {
- // default page num
- $currentpage = 1;
- } // end if
- // if current page is greater than total pages...
- if ($currentpage > $totalpages) {
- // set current page to last page
- $currentpage = $totalpages;
- } // end if
- // if current page is less than first page...
- if ($currentpage < 1) {
- // set current page to first page
- $currentpage = 1;
- } // end if
- // the offset of the list, based on current page
- $offset = ($currentpage - 1) * $rowsperpage;
- $sql = "Select * FROM `clients` WHERE cl_active = '1' ORDER BY cl_ln LIMIT $offset, $rowsperpage";
- $result = mysql_query($sql, $conn) or die(mysql_error());
- $title="List Clients";
- include 'ctts_admin_header.php';
- ?>
- <div id="content">
- <h2>Clients List</h2>
- <table border="1" cellspacing="2" cellpadding="2">
- <tr>
- <td><font face="Arial, Helvetica, sans-serif">Client Name</font></td>
- <td><font face="Arial, Helvetica, sans-serif">Last Name</font></td>
- <td><font face="Arial, Helvetica, sans-serif">Grade</font></td>
- <td><font face="Arial, Helvetica, sans-serif">Address</font></td>
- <td><font face="Arial, Helvetica, sans-serif">City</font></td>
- <td><font face="Arial, Helvetica, sans-serif">State</font></td>
- <td><font face="Arial, Helvetica, sans-serif">Zip Code</font></td>
- <td><font face="Arial, Helvetica, sans-serif">Resides With</font></td>
- </tr>
- <?php
- // range of num links to show
- $range = 3;
- // if not on page 1, don't show back links
- if ($currentpage > 1) {
- // show << link to go back to page 1
- echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
- // get previous page num
- $prevpage = $currentpage - 1;
- // show < link to go back to 1 page
- echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
- } // end if
- // loop to show links to range of pages around current page
- for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
- // if it's a valid page number...
- if (($x > 0) && ($x <= $totalpages)) {
- // if we're on current page...
- if ($x == $currentpage) {
- // 'highlight' it but don't make a link
- echo " [<b>$x</b>] ";
- // if not current page...
- } else {
- // make it a link
- echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
- } // end else
- } // end if
- } // end for
- // if not on last page, show forward and last page links
- if ($currentpage != $totalpages) {
- // get next page
- $nextpage = $currentpage + 1;
- // echo forward link for next page
- echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
- // echo forward link for lastpage
- echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
- } // end if
- while ($rows = mysql_fetch_assoc($result)){
- $num=count($rows);
- ?>
- <tr>
- <td width="150"><font face="Arial, Helvetica, sans-serif"><a href="details_client.php?id=<?php echo $id_clients;?>"><?php echo $row['cl_fn'];?> <?php echo $row['cl_ln'];?></a></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><?php echo $row['cl_ln'];?></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><?php echo $row['cl_grade'];?></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><?php echo $row['cl_address'];?></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><?php echo $row['cl_city'];?></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><?php echo $row['cl_state'];?></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><?php echo $row['cl_zip'];?></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><?php echo $row['cl_resides_with'];?></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><a href="edit_clients_form.php?id_aides=<?php echo $row['id_auth'];?>">Edit</a></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><a href="add_schedule_form.php?id_clients=<?php echo $row['id_clients'];?>">View Schedule</a></font></td>
- <td><font face="Arial, Helvetica, sans-serif"><a href="view_schedule_form.php?id_clients=<?php echo $row['id_clients'];?>">Add Schedule</a></font></td>
- </tr>
- <?php
- }
- ?>
- </table>
- <?php
- echo "Total Records: $num";
- ?>
- <form name="add Car" action="add_client_form.php">
- <input type="submit" class="button" value="Add A Client"/>
- </form>
- <!-- end .content --></div>
- <!-- end content-container --></div>
- <?php include 'footer.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement