Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.31 KB | None | 0 0
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <title>View Records</title>
  5. <link rel="stylesheet" type="text/css" href="css/style.css">
  6. </head>
  7. <body>
  8. <?php
  9. include("header.php");
  10. require('config.php');
  11.  
  12. $tableName = "tracking_records";
  13. $targetpage = "view.php";
  14. $limit = 10;
  15.  
  16. $query = "SELECT COUNT(*) as num FROM $tableName";
  17. $total_pages = mysql_fetch_array(mysql_query($query));
  18. $total_pages = $total_pages['num'];
  19.  
  20. $stages = 10;
  21.  
  22. $getpage = (isset($_GET['page'])) ? (int)$_GET['page'] : 0;
  23. $page = mysql_escape_string($getpage);
  24.  
  25. if($page){
  26. $start = ($page - 1) * $limit;
  27. }else{
  28. $start = 0;
  29. }
  30.  
  31. $query1 = "SELECT * FROM $tableName LIMIT $start, $limit";
  32. $result = mysql_query($query1) or die(mysql_error());
  33.  
  34. if($page == 0){$page = 1;}
  35. $prev = $page - 1;
  36. $next = $page + 1;
  37. $lastpage = ceil($total_pages/$limit);
  38. $LastPagem1 = $lastpage - 1;
  39.  
  40. $paginate = '';
  41. if($lastpage > 1){
  42. $paginate .= "<div class='paginate'>";
  43. if($page > 1){
  44. $paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
  45. }else{
  46. $paginate.= "<span class='disabled'>previous</span>";
  47. }
  48. if($lastpage < 7 + ($stages * 2)){
  49. for($counter = 1; $counter <= $lastpage; $counter++){
  50. if($counter == $page){
  51. $paginate.= "<span class='current'>$counter</span>";
  52. }else{
  53. $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";
  54. }
  55. }
  56. }
  57. elseif($lastpage > 5 + ($stages * 2)){
  58. if($page < 1 + ($stages * 2)){
  59. for($counter = 1; $counter < 4 + ($stages * 2); $counter++){
  60. if($counter == $page){
  61. $paginate.= "<span class='current'>$counter</span>";
  62. }else{
  63. $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";
  64. }
  65. }
  66. $paginate.= "...";
  67. $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
  68. $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
  69. }
  70. // Middle hide some front and some back
  71. elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)){
  72. $paginate.= "<a href='$targetpage?page=1'>1</a>";
  73. $paginate.= "<a href='$targetpage?page=2'>2</a>";
  74. $paginate.= "...";
  75. for($counter = $page - $stages; $counter <= $page + $stages; $counter++){
  76. if($counter == $page){
  77. $paginate.= "<span class='current'>$counter</span>";
  78. }else{
  79. $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";
  80. }
  81. }
  82. $paginate.= "...";
  83. $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
  84. $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";
  85. }else{
  86. $paginate.= "<a href='$targetpage?page=1'>1</a>";
  87. $paginate.= "<a href='$targetpage?page=2'>2</a>";
  88. $paginate.= "...";
  89. for($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++){
  90. if($counter == $page){
  91. $paginate.= "<span class='current'>$counter</span>";
  92. }else{
  93. $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";
  94. }
  95. }
  96. }
  97. }
  98. if($page < $counter - 1){
  99. $paginate.= "<a href='$targetpage?page=$next'>next</a>";
  100. }else{
  101. $paginate.= "<span class='disabled'>next</span>";
  102. }
  103. $paginate.= "</div>";
  104. }
  105. echo '&nbsp;&nbsp;&nbsp;'.$total_pages.' Results';
  106. echo $paginate;
  107. ?>
  108. <table border='1'>
  109. <tr>
  110. <th>Contract #</th><th>Date</th>
  111. <th>Vessel</th><th>Work Description</th>
  112. <th>Specs PKG</th><th>Period of Performance</th>
  113. <th>Required Delivery Date</th><th>IGE Amount</th>
  114. <th>PM / SBS / MM</th><th>IDIQ</th>
  115. <th>Solicitation #</th><th>RFP/RFQ Closing Date</th>
  116. <th>RFP/RFQ Closing Time</th><th>Status</th>
  117. <th>Award Amount</th><th>Award Date</th>
  118. <th>Contractor</th><th>Remarks</th>
  119. <th>Edit / Delete</th>
  120. </tr>
  121. <?php
  122. while($row = mysql_fetch_array($result))
  123. {
  124. echo "<tr>
  125. <td>$row[0]</td><td>$row[1]</td>
  126. <td>$row[2]</td><td>$row[3]</td>
  127. <td>$row[4]</td><td>$row[5]</td>
  128. <td>$row[6]</td><td>$row[7]</td>
  129. <td>$row[8]</td><td>$row[9]</td>
  130. <td>$row[10]</td><td>$row[11]</td>
  131. <td>$row[12]</td><td>$row[13]</td>
  132. <td>$row[14]</td><td>$row[15]</td>
  133. <td>$row[16]</td><td>$row[17]</td>
  134. <td>
  135. <a href='edit.php?cn=$row[0]'>Edit</a><br />
  136. <a href='delete.php?cn=$row[0]' onClick="return confirm('Delete this record?')";>Delete</a>
  137. </td>
  138. </tr>";
  139. }
  140. echo "</table>";
  141. mysql_free_result($result);
  142. mysql_close($connection);
  143. ?>
  144. </body>
  145. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement