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
SWF image using php?
Hello once again.My latest en devour requires me to produce an image of a static .swf that is embedded on a page.Unfortunately, it has a selection of variables passed to it.EgCode: <object
can i optmize image to 50% quality before uploading 2 server
Hi therei have jus written a php program to upload and display images but when i try to upload them it takes a long time to upload if the file is big. But the big problem is when i try to display
limitations on array_unique()
Does any one know what/how imitations are applied to array_unique? I have an issue where no matter how big (as in over this limit) the array is array_unique always returns an array with 32768
Displaying data from database into a 2 dimensional table
Good day!I'm a beginner in PHP and I'm not expecting a full coding for this qestion. I'm just looking for hints and pointers as to how to solve this problem so that I can learn it myself.I have a
constructor ?
i have written this program and made 3 constructors in the class and i want to call them in the main and i cant can any one help me and tell me how could i call them in the main
Wordpress IE issue
So I am trying to add the background shadow to my wordpress page. It works fine in Firefox but does not in IE.So here is the original code: <?php get_header(); ?><?php
Running External Scripts
I am very new to PHP and am not even sure what I'm asking is possible. I have just installed mediaWiki on my site and I'm trying to install some extensions. In order to install the Search
License Issue - service type user
Hi,
Doubles are giving me problems
Ok so, first of all i made a double = 0.05, but when running the debugger it shows up as 0.04999. I know this has something to do with how doubles store but its causing problems for me. Anyway, in the
Unique Visitor Tracking
Hello. Currently, I run a voting site where voters are tracked by their IP address and can only vote once every 12 hours.The system works well, except it can be exploited very easily. Visitor's only