Hey all,
As you can see in the code below my ceiling for results per page is 4. However the number of results printed is only 2 per page. Any ideas?
<?
$city = mysql_real_escape_string($_GET['city']);
if(isset($city)){
if($city == "cityA"){
//Get current page
if(isset($_GET['pageno'])){
$pageno = $_GET['pageno'];
}else{
$pageno = 1;
}
$query = "SELECT count(*) FROM `Table` WHERE `city` = '".$city."' AND `active` = 'Yes'";
$result = mysql_query($query);
$query_data = mysql_fetch_row($result);
$numrows = $query_data[0];
$rows_per_page = 4;
$lastpage = ceil($numrows/$rows_per_page);
//Check to ensure that $pageno is between 1 and $lastpage
$pageno = (int)$pageno;
if ($pageno < 1) {
$pageno = 1;
}elseif ($pageno > $lastpage) {
$pageno = $lastpage;
}
//Construct the LIMIT clause for the MySQL SELECT statement
$limit = "LIMIT " .($pageno - 1) * $rows_per_page ."," .$rows_per_page;
$query2 = "SELECT * FROM `Table` WHERE `active` = 'Yes' AND `city` = '".$city."' $limit";
$result2 = mysql_query($query2);
}
?>
...Static HTML Goes Here...
<?
if($numrows > 0){
while($info = mysql_fetch_assoc($result2)){
++$x;
if($x % 2 == 1){
++$y;
if($y % 2 == 1) {
$row_style = "d0";
}else{
$row_style = "d1";
}
echo '<tr class=' . $row_style . '>';
echo "<td valign='middle' width='200'>Cell 1 Data Here</td><td valign='top' width='600'>Cell 2 Data Here</td>";
echo "</tr>";
}
}
}else{
}
?>
TIA!