Hi all,
I've worked out my pagination script and its paginating fine until I click next from page 2 at which point it stops displaying results. I know its something really simple, but can't see what lol.
Here is my code, anyone able to help?
Code: $connection = mysql_connect($hostname, $username, $password);
#
    if (!$connection) {
#
       die("A connection to the server could not be established");
#
    }
#
/*Select Database */
#
    mysql_select_db($database) or die("Database could not be selected!");
#
 
#
/*set variables*/
#
if (isset($_GET['MerchantType']) && isset($_GET['County'])){
#
    $MerchantType = $_GET["MerchantType"];
#
    $County = $_GET["County"];
#
    echo $County . "  " . $MerchantType;
#
}
#
 
#
/* Set current, prev and next page */
#
$page = (!isset($_GET['page']))? 1 : $_GET['page'];
#
$next = $page + 1;
#
$prev = $page - 1;
#
 
#
/* Max results per page */
#
$max_results = 5;
#
 
#
if (!$connection) {
#
    die("A connection to the server could not be established");
#
}
#
/* Select Database */
#
mysql_select_db($database) or die("Database could not be selected!");
#
 
#
 
#
/* Figre out how many items there are in your DB */
#
$q = "SELECT * FROM $tablename WHERE County = '$County' AND MerchantType = '$MerchantType'";
#
$result = mysql_query($q) or die(mysql_error());
#
$total_results_pages = mysql_num_rows($result);
#
 
#
/* Must know where to begin grabbing the results from the DB */
#
$limitvalue = $page * $max_results - ($max_results);
#
 
#
// query
#
$q = "SELECT * FROM $tablename WHERE County = '$County' AND MerchantType = '$MerchantType' LIMIT $limitvalue, $max_results";
#
$result = mysql_query($q) or die(mysql_error());
#
$total_results = mysql_num_rows($result);
#
 
#
$total_pages = ceil($total_results_pages / $max_results);
#
 
#
 
#
 
#
echo '$total_results_pages = '.$total_results_pages;
#
echo '
';
#
echo '$total_results = '.$total_results;
#
echo '
';
#
echo '$max_results = '.$max_results;
#
echo '
';
#
echo '$total_pages = '.$total_pages;
#
echo '
';
#
echo '$page = '.$page;
#
echo '
';
#
echo '$next = '.$next;
#
echo '
';
#
echo '$prev = '.$prev;
#
echo '
';
#
echo '$limitvalue = '.$limitvalue;
#
echo '<hr>';
#
 
#
 
#
while ($row_details = mysql_fetch_array($result))
#
    {                               
#
    echo    '
        <table class="results" border="1" bordercolor="#1d9346">
        <style="background-color:#FFFFFF" width="800" cellpadding="3" cellspacing="3">
        <tr>
        <td width="200" align="left" rowspan="7"><img src = "images/Test.png" /></td>
        </tr>
        <tr>
        <td width="573" height="27" align="left">Name: '.$row_details['MerchantName'].'</td>
        </tr>
        <tr>
        <td height="27" align="left">Address 1: '.$row_details['AddressLine1'].'</td>
        </tr>
        <tr>
        <td height="27" align="left">Address 2: '.$row_details['AddressLine2'].'</td>
        </tr>
        <tr>
        <td height="27" align="left">Telephone: '.$row_details['Telephone'].'</td>
        </tr>
        <tr>
        <td height="27" align="left">Website: '.$row_details['Website'].'</td>
        </tr>
        <tr>
        <td height="27" align="left">Description: '.$row_details['Description'].'</td>
        </tr>
        </table><br />';
#
    }
#
 
#
// show next
#
if ($page == 1 && $page < $total_pages)
#
{
#
    echo '<a href="?MerchantType='.$MerchantType.'&County='.$County.'&page='.$next.'">Next</a>';
#
}
#
 
#
// shoe prev & next
#
if ($page > 1 && $page < $total_pages)
#
{
#    // prev link
#
    echo '<a href="?MerchantType='.$MerchantType.'&County='.$County.'$page='.$prev.'">Previous</a>  |';
    // next link
#
    echo '<a href="?MerchantType='.$MerchantType.'&County='.$County.'$page='.$next.'">Next</a> ';
#
#
}
#
 
#
// show prev
#
if ($page > 1 && $page ==  $total_pages)
#
{
#
    echo '<a href="?MerchantType='.$MerchantType.'&County='.$County.'&page='.$prev.'">Previous</a>';
#
}
Sam
read integers that returns a negative or prints the average
Im trying to finish this homework assignment by tommarow afternoon and I keep getting stuck.
redirect standard error and assert (how to?)
How do you redirect standard error and assert?---(Why? I am creating an web app and assert does not show on the webpage. I do not think standard error does either. Not sure, but fairly certain.
ldap connection
We are using ldap to get user information from the domain controller. It was working before. Recently I found the application is hanging at ldap_connect. It doesn't return any message. i am not sure
Registration
ok so i have a site where people can register and login which works now thanks to someone on here that pointed out my error :-)Now my users click my links they can view the content without logging in,
Problems with strings containing
Hey all,I have encountered something strange in a script. I am trying to write an XML header and then fill in the file:Code: $xmlFile = "fetchableData.xml";$fh = fopen($xmlFile,
search query in mysql in php problem
my search query wont work, i know, that my codes are correct.please helpCode: [Select]<table width="300" border="0" align="center" cellpadding="0"
socket makes browser hang...
I have a socket server, and I am having a problem at the moment...A browser sends a http header request to the server, but... some browsers send one request for one file, and others want 2. For
Simple code help with redirects
I am trying to figure out a redirect script that detects if the browser is IE 7 and if it does, redirect the user to another page. Is this even possible?
Retreiving objects from Sessions
Hi all,I am getting really frustrated with storing and retreiving objects from a session. But it may be because of my lack of knowledge in sessions First some system specs:OS - Vista Home
Adding Outlook 2007 items via file upload
I am looking for a way to be able to attach an Outlook item (an email message) in an ASP.NET 3.5 application. Similar to when in Outlook and sending an attachment, you can select either a file, or an