Code: Select all
$query = "SELECT COUNT(id) AS numrows FROM products WHERE pause = 'off' LIMIT $offset, $rowtoRetrieve";Moderator: General Moderators
Code: Select all
$query = "SELECT COUNT(id) AS numrows FROM products WHERE pause = 'off' LIMIT $offset, $rowtoRetrieve";Code: Select all
<div class='head'>new products</div>
<?php
$cookietype = $_COOKIE['type'];
include "dbconn.php";
$rowsPerPage = 36;
$pageNum = 1;
if(isset($_GET['pagenum']))
{
$pageNum = $_GET['pagenum'];
}
$offset = ($pageNum - 1) * $rowsPerPage;
$rowToRetrieve = 150;
$result = mysql_query ("SELECT * FROM products WHERE pause = 'off' ORDER BY id DESC LIMIT $offset, $rowToRetrieve");
while ($row = mysql_fetch_object($result))
{
$title = "$row->title";
$findtitle ="/ /";
$replacetitle ="-";
$titlereplace = preg_replace ($findtitle, $replacetitle, $title);
$categ = "$row->catname";
$findcateg ="/ /";
$replacecateg ="-";
$categreplace = preg_replace ($findcateg, $replacecateg, $categ);
$subcateg = "$row->subname";
$findsubcateg ="/ /";
$replacesubcateg ="-";
$subcategreplace = preg_replace ($findsubcateg, $replacesubcateg, $subcateg);
$count = $count + 1;
if ($count == 4 || $count == 8 || $count == 12 || $count == 16 || $count == 20 || $count == 24 || $count == 28 || $count == 32 || $count == 36 || $count == 40 || $count == 44 || $count == 48 || $count == 52 || $count == 56 || $count == 60)
{ echo "<div class='cat_prodlistbox_noline'>";}
else { echo "<div class='cat_prodlistbox'>";}
echo "<a href='/product/$row->catid/$categreplace/$row->subid/$subcategreplace/$row->id/$titlereplace' style='text-decoration: none'>
<div class='cat_producttitle'>$row->title<br/>Only ";
printf ("£%.2f", $row->price);
echo "</div>";
if ($row->photoprimary == NULL) { echo "<img src='images/blank.gif' border='0' style='border: 1px solid #000000' width='142px'/><img src='images/imageshadow.png' border='0' class='shadowmedium' />";}
if ($row->photoprimary <> NULL) { echo "<img src='images/productphotos/small/$row->photoprimary' border='0' width='142px' style='border: 1px solid #000000'/><img src='images/imageshadow.png' class='shadowmedium' border='0'/>";}
echo "</a>
</div>";
if ($count == 4 || $count == 8 || $count == 12 || $count == 16 || $count == 20 || $count == 24 || $count == 28 || $count == 32 || $count == 36 || $count == 40 || $count == 44 || $count == 48 || $count == 52 || $count == 56 || $count == 60)
{
if (strpos($_SERVER['HTTP_USER_AGENT'],'Firefox')!==FALSE) {
echo "<div style='clear: both;' /><br/><img src='images/divider.png' /></div>";}
elseif (strpos($_SERVER['HTTP_USER_AGENT'],'Safari')!==FALSE) {
echo "<div style='clear: both;' /><br/><img src='images/divider.png' /></div>";}
elseif (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==FALSE) {
echo "<div style='clear: both;' /><br/><img src='images/divider_ie.png' /></div>";}
else { echo "<div style='clear: both;' /><br/><img src='images/divider_nogap.png' /></div>";}
}
}
mysql_free_result($result);
echo "<br/><br/><br/>";
$query = "SELECT COUNT(id) AS numrows FROM products WHERE pause = 'off' LIMIT $offset, $rowToRetrieve";
$categ = "$cname";
$findcateg ="/ /";
$replacecateg ="-";
$categreplace = preg_replace ($findcateg, $replacecateg, $categ);
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page "; // no need to create a link to current page
}
else
{
$nav .= " <a href=\"/categ/page/$catid/$categreplace/$page\" class='bodylink'>$page</a>";
}
}
// creating previous and next link
// plus the link to go straight to
// the first and last page
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"/categ/page/$catid/$categreplace/$page\" class='bodylink'>[Prev]</a> ";
$first = " <a href=\"/categ/$catid/$categreplace/\" class='bodylink'>[First Page]</a>";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"/categ/page/$catid/$categreplace/$page/\" class='bodylink'>[Next]</a>";
$last = " <a href=\"/categ/page/$catid/$categreplace/$maxPage\" class='bodylink'>[Last Page]</a>";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
echo "<div class='navpages'>" . $first . $prev . $nav . $next . $last . "</div>";
?>