Olive Branch MS Chamber of Commerce (circa Oct 1999)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

99 lines
2.3 KiB

  1. <html>
  2. <head>
  3. <title>Olivebranch MS</title>
  4. </head>
  5. <body>
  6. <form method="post" action="listall.php3">
  7. <?
  8. $lines_per_page = 15;
  9. // connect to the database
  10. $connection = pg_connect("localhost", "5432", "olivebranch");
  11. $query = "SELECT * FROM member";
  12. $result = pg_exec($connection, $query);
  13. $total_rows = pg_numrows($result);
  14. switch($bsact)
  15. {
  16. case "First Page":
  17. $begin = 0;
  18. break;
  19. case "Previous Page":
  20. $begin -= $lines_per_page;
  21. if($begin < 0) $begin = 0;
  22. break;
  23. case "Next Page":
  24. $begin += $lines_per_page;
  25. if($begin > ($total_rows - $lines_per_page)) $begin = $total_rows - $lines_per_page;
  26. break;
  27. case "Last Page":
  28. $begin = $total_rows - $lines_per_page;
  29. break;
  30. default:
  31. $begin = 0;
  32. break;
  33. }
  34. print("<TABLE border=1>\n");
  35. $last_row = $begin + $lines_per_page;
  36. if($last_row > $total_rows) $last_row = $total_rows;
  37. print("<input type=\"hidden\" name=\"begin\" value=\"" . $begin . "\">");
  38. for($row = $begin; $row < $last_row; $row++)
  39. {
  40. print("<TR>\n");
  41. print("<td>$row</td>");
  42. for($field = 0; $field < pg_numfields($result); $field++)
  43. {
  44. print("<td>");
  45. if(pg_fieldisnull($result, $row, $field))
  46. {
  47. $price = "NULL";
  48. }
  49. else
  50. {
  51. print(pg_result($result, $row, $field));
  52. }
  53. print("</td>\n");
  54. }
  55. print("</TR>\n");
  56. }
  57. print("</TABLE>");
  58. // close connection to the database
  59. pg_freeresult($result);
  60. pg_close($connection);
  61. $total_pages = ($total_rows / $lines_per_page) + 1;
  62. settype($total_pages, "integer");
  63. if($begin == ($total_rows - $lines_per_page)) $page = $total_pages;
  64. else
  65. {
  66. $page = ($begin / $lines_per_page) + 1.99;
  67. settype($page, "integer");
  68. }
  69. print("<br>Page $page of $total_pages<br>\n");
  70. if($total_rows > $lines_per_page)
  71. {
  72. if($begin > 0)
  73. {
  74. print("<input type=\"submit\" name=\"bsact\" value=\"First Page\">");
  75. print("<input type=\"submit\" name=\"bsact\" value=\"Previous Page\">");
  76. }
  77. if($begin != ($total_rows - $lines_per_page))
  78. {
  79. print("<input type=\"submit\" name=\"bsact\" value=\"Next Page\">");
  80. print("<input type=\"submit\" name=\"bsact\" value=\"Last Page\">");
  81. }
  82. }
  83. ?>
  84. </form>
  85. </body>
  86. </html>