$lines_per_page = 15; // connect to the database $connection = pg_connect("localhost", "5432", "olivebranch"); $query = "SELECT * FROM member"; $result = pg_exec($connection, $query); $total_rows = pg_numrows($result); switch($bsact) { case "First Page": $begin = 0; break; case "Previous Page": $begin -= $lines_per_page; if($begin < 0) $begin = 0; break; case "Next Page": $begin += $lines_per_page; if($begin > ($total_rows - $lines_per_page)) $begin = $total_rows - $lines_per_page; break; case "Last Page": $begin = $total_rows - $lines_per_page; break; default: $begin = 0; break; } print("
\n"); $last_row = $begin + $lines_per_page; if($last_row > $total_rows) $last_row = $total_rows; print("
"); for($row = $begin; $row < $last_row; $row++) { print("
\n"); print("
$row
"); for($field = 0; $field < pg_numfields($result); $field++) { print("
"); if(pg_fieldisnull($result, $row, $field)) { $price = "NULL"; } else { print(pg_result($result, $row, $field)); } print("
\n"); } print("
\n"); } print("
"); // close connection to the database pg_freeresult($result); pg_close($connection); $total_pages = ($total_rows / $lines_per_page) + 1; settype($total_pages, "integer"); if($begin == ($total_rows - $lines_per_page)) $page = $total_pages; else { $page = ($begin / $lines_per_page) + 1.99; settype($page, "integer"); } print("
Page $page of $total_pages
\n"); if($total_rows > $lines_per_page) { if($begin > 0) { print("
"); print("
"); } if($begin != ($total_rows - $lines_per_page)) { print("
"); print("
"); } } ?>