PHP Pagination duplicating content from first page onto all other 'next'
pages
I'm having a pagination problem. When I click to the second, third, or
whatever page, the content is just duplicated from the first page and
doesn't display the next set of products.
I'm using this pdo pagination plugin
https://github.com/BenGriffiths/pdo-mysqli-pagination
require('includes\head-info.php')
?>
</head>
<body style="background-color:#444444;">
<?php
if(isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
try
{
$DBH = new PDO('mysql:host=localhost;dbname=---','---','---');
}
catch (PDOException $e)
{
echo 'Error!: '.$e->getMessage();
die();
}
$options = array(
'url' =>
'http://localhost/Single-Serve-Coffee/beverage-roast/' .
$Roasted . '?page=*VAR*',
'db_handle' => $DBH
);
try
{
$pagination = new pagination($page,
'SELECT products.ProductID, products.Name, products.Brand,
products.Image, MIN(merchants.Price) AS Price,
products.BevType, products.Count, products.Roast
FROM merchants
JOIN products
ON merchants.ProductID = products.ProductID
WHERE products.Roast ="' . $Roasted .'"
GROUP BY products.ProductID
ORDER BY products.Name ASC', $options);
}
catch(paginationException $e)
{
echo $e;
exit();
}
if($pagination->success == true)
{
$result = $pagination->resultset->fetchAll();
$i=0;
foreach($result as $row)
{
$ProductID = $row['ProductID'];
$Brand = $row['Brand'];
$Name = $row['Name'];
$Image = $row['Image'];
$Price = $row['Price'];
$BevType = $row['BevType'];
$Count = $row['Count'];
echo "<li class='mix bev-slider'
vocab='http://schema.org/' typeof='Product'>";
echo "<div class='touchslider bev-slider'>";
echo "<div class='touchslider-viewport bev-slider'>";
echo "<div class='touchslider-div bev-slider'
style='width: 310px;'>";
echo "<div class='touchslider-item bev-slider'>";
echo "<h1><span property='brand'>" . $Brand . "</span>
<span property='name'>" . $Name . "</span></h1>";
echo "<img class='image-swipe' src='img/swipe.png'
alt='Swipe to the Left Indicator'/>";
echo "<h2>" . $Count . " Pack of " . $BevType . "</h2>";
echo "<img class='product-img' property='image'
src='img/products/" . $Image . "' alt='" . $Brand . "
" . $Name . " Image'/></a>";
echo "</div>";
echo "<div class='touchslider-item bev-slider'
id='inside-slide'>";
echo "<h2><span property='Brand'><em>" . $Brand .
"</span> <span property='Name'>" . $Name .
"<span></em></h2></br>";
echo "<h2>" . $Count . " Pack of " . $BevType .
"</h2></br>";
echo "<div property='offers' typeof='AggregateOffer'>";
echo "<h2>Lowest Price <span property='lowPrice'>$" .
$Price . "</span></h2></br>";
$url = "beverages/" . $Brand . "/" . $Name . "-" .
$ProductID;
$urlNeat = str_replace(" ", "-", $url);
$urlNeat = strtolower($urlNeat);
$urlNeat = str_replace("®", "", $urlNeat);
echo "<a href='" . $urlNeat . "' class='btn
btn-info'>View Details</a>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</li>";
}
echo "</ul><!--end Grid / products-wrapper-->";
echo "</div><!--end span10-->";
echo "<div class='pagination'>";
echo $pagination->links_html;
echo "</div>";
echo "</div> <!--end fluid row-->";
echo "</div><!--end fluid container-->";
}
include_once 'includes/products-categories-js.php';
?>
</body>
</html>
No comments:
Post a Comment