jasonindus
Programmer
for the life of me i just can't figure out what is going wrong. the pagination seems to work a i get the next and previous links, but my results (looped table) doesn't appear, could be my query or something?
Code:
//db settings
$records_per_page = 4;
//find out how many records are in the table
$count_query = "SELECT count(*)
FROM 07_articles
WHERE supplier_id='1008'
AND deleted <> 'remove'";
$rh = mysql_query($count_query);
list ($record_count) = mysql_fetch_array($rh);
//calculate the maximum "page" that can be displayed.
$max_pages = floor($record_count / $records_per_page);
//This logic takes care of reacting to input.
if (isset($_GET['page']))
{
if ($_GET['page'] > 1)
{
if ($_GET['page'] > $max_pages)
{
$current_page = $max_pages;
}
else
{
$current_page = $_GET['page'];
}
}
else
{
$limit_start = 0;
$current_page = 1;
}
$limit_start = $current_page * $records_per_page;
}
else
{
$limit_start = 0;
$current_page = 1;
}
//echo 'max_pages'; echo ''.$max_pages.''; echo '<br>';
// Get data
//query the database for the required records
$data_query = "SELECT *
FROM 07_articles
WHERE supplier_id='1008'
AND deleted <> 'remove'
ORDER by item_id DESC
DESC
LIMIT " . $limit_start . ", " . $records_per_page;
$rh = mysql_query ($data_query);
// test start
echo '<table border="0" cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td valign="top">';
echo '<table class="table_border_red" width="295" border="0" cellspacing="0" cellpadding="0">';
echo '<tr>';
echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?page=' . ($current_page - 1) .' ">previous</a></td>';
echo '<td width="10"></td>';
echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?page=' . ($current_page + 1) .' ">next</a></td>';
echo '</tr>';
echo '</table>';
echo '</td>';
echo '</tr>';
while ($content_row = mysql_fetch_array($rh)) {
//while($profile_row = mysql_fetch_array( $result )) {
echo '<tr>';
echo '<td valign="top"><img src="images/bullet_arrow_down.png"></td>';
echo '<td valign="top"><a href="?article='.$content_row['unique_id0'].'">'.$content_row['item_name'].'</a></td>';
echo '</tr>';
echo '<tr>';
echo '<td valign="top" height="10"></td>';
echo '</tr>';
}
echo '</table>';