I can't seem to figure out whats wrong with this pagination limit. I've managed to run the SQL statements fine directly from MySQL, but for some reason nothing wants to print. All that I get are ten dashes for the limit, but no data to the right or left. Any Ideas?
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
// Set Script Variables
$DB_Host="localhost";
$DB_Name="test";
$DB_User="dbuser";
$DB_Pass="dbpass";
$Per_Page=10;
// Open MySQL Connection
$Connection=mysql_connect($DB_Host, $DB_User, $DB_Pass);
// Run The Query Without a Limit to get Total result
$SQL="SELECT COUNT() AS Total FROM inve";
$SQL_Result=mysql_db_query($DB_Name, $SQL);
$SQL_Result_Array=mysql_fetch_array($SQL_Result);
$Total=$SQL_Result_Array[’Total’];
// Create a new SELECT Query with the ORDER BY clause and without the COUNT()
$SQL="SELECT FROM inve ORDER BY itemid";
// Append a LIMIT clause to the SQL statement
if (empty($GET[’Result_Set’]))
{
$Result_Set=0;
$SQL.=" LIMIT $Result_Set, $Per_Page";
}else
{
$Result_Set=$GET[’Result_Set’];
$SQL.=" LIMIT $Result_Set, $Per_Page";
}
// Run The Query With a Limit to get result
$SQL_Result=mysql_db_query($DB_Name, $SQL);
$SQL_Rows=mysql_num_rows($SQL_Result);
// Display Results using a for loop
for ($a=0; $a < $SQL_Rows; $a++)
{
$SQL_Array=mysql_fetch_array($SQL_Result);
$itemid=$SQL_Array[’itemid’];
$description_1=$SQL_Array[’description_1’];
$description_2=$SQL_Array[’description_2’];
echo "$itemid - $description_1 $description_2<BR><BR>";
}
// Create Next / Prev Links and $Result_Set Value
if ($Total>0)
{
if ($Result_Set<$Total && $Result_Set>0)
{
$Res1=$Result_Set-$Per_Page;
echo "<A
HREF=\"test.php?Result_Set=$Res1\"><;<;
Previous Page</A> ";
}
// Calculate and Display Page # Links
$Pages=$Total / $Per_Page;
if ($Pages>1)
{
for ($b=0,$c=1; $b < $Pages; $b++,$c++)
{
$Res1=$Per_Page $b;
echo "<A
HREF=\"test.php?Result_Set=$Res1\">$c</A> \n";
}
}
if ($Result_Set>=0 && $Result_Set<$Total)
{
$Res1=$Result_Set+$Per_Page;
if ($Res1<$Total)
{
echo " <A
HREF=\"test.php?Result_Set=$Res1&Keyword=\">Next
Page >></A>";
}
}
}
// Close Database Connection
mysql_close($Connection);
?>
</body>
</html>