beginning pagination
Posted: Tue Jun 29, 2010 9:31 am
I need to use some form of pagination to sort through some user records. Client side pagination will not work due to the way I have my site set up. I have found a tutorial for server side pagination at http://articles.sitepoint.com/article/p ... pagination. I believe I have the right setup, but obviously not. The table does not get filled in properly. Hope someone could shed some light on this topic. Thanks in advanced!
My code
My code
Code: Select all
<?php
$email = $_SESSION["email"];
$connection = mysql_connect("*********","*******","******");
//try to connect to database
if ($connection) {
mysql_select_db("******", $connection);
$get_num = mysql_fetch_row(mysql_query("SELECT * FROM accounts WHERE email = '$email'"));
$num = $get_num[0];
$query = mysql_query("SELECT * FROM support WHERE customer='$num'");
$num_rows = mysql_num_rows($query);
if ($num_rows > 0) {
require_once "Paginated.php";
require_once "TableLayout.php";
$requests = array();
$i = 0;
while($fields = mysql_fetch_row($query)) {
$requests[i] = $fields;
$i++;
}
$pagedResults = new Paginated($requests, 3, 1);
echo "<table id='pageme'><thead><tr><th align='center'>Request #</th><th align='center'>Date</th><th align='center'>Subject</th><th align='center'>Status</th></tr></thead><tbody>";
while($row = $pagedResults->fetchPagedRow()) {
echo "<tr><td align='center'>$row[0]</td><td>$row[1]</td><td>$row[3]</td><td>$row[5]</td></tr>";
}
$pagedResults->setLayout(new TableLayout());
echo "</tbody><tfoot>$pagedResults->fetchPagedNavigation()</tfoot></table>";
}
else {
echo "<table border='1' style='border-collapse:collapse'><thead><tr><th align='center'>Request #</th><th align='center'>Date</th><th align='center'>Subject</th><th align='center'>Status</th></tr></thead>";
echo "<tbody><tr><td colspan='5'>You have not yet submited a request.</td></tr></tbody>";
echo "</table>";
}
}
else {
die("Not Connected: " . mysql_error());
}
mysql_close($connection);
?>