This_Is_Craig
01 Nov 2009, 11:23 AM
I've been reading through some tutorials on pagination, and I'm trying to implement it into a current project, but I'm not having the best luck with it. I already have some PHP pulling info from a database and everything how I'd like, so that's all set, but I'm not sure how to implement that into some PHP for pagination.
The PHP I have right now that I'd like to paginate is this:
<?PHP
$user_name = "####";
$password = "####";
$database = "####";
$server = "####";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
?>
<div id="listing_top"></div>
<div id="listings">
<?PHP
if ($db_found) {
$SQL = "SELECT * FROM tbl_rest_list ORDER BY Name";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_array($result)) {
if(!empty($db_field['url'])) {
echo '<div class="name">' . "<h3>" . $html = '<a href="' . $db_field['url'] . '">' . $db_field['Name'] . '</a>' . "<h3>" . "</div>";
}
else {
echo "<div>" . "<h3>" . $html = $db_field['Name'] . "<h3>" . "</div>";
}
echo "<div>" . $db_field['Street'] . "</div>";
echo "<div>" . $db_field['City'] . ", " . $db_field['State'] . "</div>";
echo "<div>" . "<em>Phone: </em>" . "<strong>" . $db_field['Phone'] . "</strong>" . "</div>";
echo "<div>" . $db_field['Email'] . "</div>";
echo '<div id="type">' . "<em>Type of Food: </em>" . $db_field['Type'] . '</div>';
}
mysql_close($db_handle);
}
else {
echo "Database NOT Found ";
mysql_close($db_handle);
}
?>
</div>
<div id="listing_bottom"></div>
Thanks in advance for any help. You guys have already helped me a ton in understanding PHP. I really appreciate it.
The PHP I have right now that I'd like to paginate is this:
<?PHP
$user_name = "####";
$password = "####";
$database = "####";
$server = "####";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
?>
<div id="listing_top"></div>
<div id="listings">
<?PHP
if ($db_found) {
$SQL = "SELECT * FROM tbl_rest_list ORDER BY Name";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_array($result)) {
if(!empty($db_field['url'])) {
echo '<div class="name">' . "<h3>" . $html = '<a href="' . $db_field['url'] . '">' . $db_field['Name'] . '</a>' . "<h3>" . "</div>";
}
else {
echo "<div>" . "<h3>" . $html = $db_field['Name'] . "<h3>" . "</div>";
}
echo "<div>" . $db_field['Street'] . "</div>";
echo "<div>" . $db_field['City'] . ", " . $db_field['State'] . "</div>";
echo "<div>" . "<em>Phone: </em>" . "<strong>" . $db_field['Phone'] . "</strong>" . "</div>";
echo "<div>" . $db_field['Email'] . "</div>";
echo '<div id="type">' . "<em>Type of Food: </em>" . $db_field['Type'] . '</div>';
}
mysql_close($db_handle);
}
else {
echo "Database NOT Found ";
mysql_close($db_handle);
}
?>
</div>
<div id="listing_bottom"></div>
Thanks in advance for any help. You guys have already helped me a ton in understanding PHP. I really appreciate it.