Advertisement
gitlez

YA: Displaying DB Records 20120715005835AA8CV0j

Jul 15th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>VIEW LETTER RECORDS</title>
  4. </head>
  5.  
  6. <script type="text/javascript">
  7. var checked=false;
  8. var frmname='';
  9. function checkedAll(frmname){
  10.     var valus=document.getElementById(frmname);
  11.     checked = (checked==false);
  12.     for(var i=0; i<valus.elements.length; i++)
  13.     {
  14.         valus.elements[i].checked=checked;
  15.     }
  16. }
  17. </script>
  18.  
  19. <?php
  20. $conn = mysql_connect("localhost","root","") or die('Couldn\'t Connect To Server<br>Reason: ' . mysql_error());
  21. mysql_select_db("pmo") or die('Couldn\'t Select Database<br>Reason: ' . mysql_error( $conn ));
  22. $per_page=10;
  23.  
  24. $total_results = mysql_num_rows($result);
  25. $total_pages = ceil($total_results / $per_page);
  26.  
  27. if (isset($_GET['page']) && is_numeric($_GET['page'])){
  28.     $show_page = (int)$_GET['page'];
  29. } else {
  30.     $show_page = 1;
  31. }
  32.  
  33. if ($show_page > 1 && $show_page <= $total_pages){
  34.     $start = ($show_page -1) * $per_page;
  35.     $end = $start + $per_page;
  36. }else{
  37.     $start = 0;
  38.     $end = $per_page;
  39. }
  40. $result=mysql_query("SELECT * FROM letter LIMIT {$start},{$end}")or die( mysql_error( $conn ));
  41.  
  42. echo "<p><b>View Page:</b> ";
  43. for ($i = 1; $i <= $total_pages; $i++){
  44.     echo "<a href='paginated.php?page=$i'>$i</a> ";
  45. }
  46. echo "</p>";
  47.  
  48. echo "<br>";
  49.  
  50. echo "<p><b>VIEW ALL LETTER DETAILS</b>";
  51. echo "<table border='3' cellpadding='5'>";
  52. echo "<tr> <th><input type='checkbox' name='checkall' onclick=' checkedAll(\"cbexample\");' ></th> <th>BIL</th> <th>SUBJECT</th> <th>DATE IN</th> <th>DATE OUT</th> <th>REFERENCE</th> <th>REMARKS</th> <th>FORMAT</th> <th>UPLOADER</th> <th></th> <th></th> </tr>";
  53. $resultColumns = Array('bil','subject','dateIn','dateOut','reference','remarks','format','uploader');
  54.  
  55. while($row = mysql_fetch_assoc($result) ){
  56.     echo '<tr>';
  57.     echo '<form id="cbexample">';
  58.     // These need to be renamed to be usefull.
  59.     echo '<td><center><input type="checkbox" name="check1"></center>';
  60.     echo '<center><input type="checkbox" name="check2"></center>';
  61.     foreach($resultColumns as $col){
  62.         echo '<td>' . $row[$col] . '</td>';
  63.     }
  64.     echo '<td><a href="edit2.php?bil=' . $row['bil'] . '">Edit</a></td>';
  65.     echo '<td><a href="delete1.php?bil=' . $row['bil'] . '">Delete</a></td>';
  66.     echo "</tr>";
  67. }
  68.  
  69. echo "</table>";
  70.  
  71. ?>
  72. <div align="bottom"><form method="link" action="suratFile.html"><input type="submit" value="CANCEL"></form></div>
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement