Code: Select all
$query = "SELECT id, catid, catname, subid, subname FROM products WHERE catid = '$c' AND catid IS NOT NULL AND pause = 'off' GROUP BY subname ASC";
$result = $pdo->query($query);
while ($cat = $result->fetch(PDO::FETCH_OBJ)) {
}Moderator: General Moderators
Code: Select all
$query = "SELECT id, catid, catname, subid, subname FROM products WHERE catid = '$c' AND catid IS NOT NULL AND pause = 'off' GROUP BY subname ASC";
$result = $pdo->query($query);
while ($cat = $result->fetch(PDO::FETCH_OBJ)) {
}Code: Select all
$c = isset($_GET['c']) ? $_GET['c'] : null;
$s = isset($_GET['s']) ? $_GET['s'] : null;That's editor-specific and doesn't mean anything to me. Why not simply pass $_GET['c'] to your prepared statement?simonmlewis wrote:Here's an oddity, at the top where I declare the variables, $c is in red, while $s is all black.
Code: Select all
$result->execute(array(':c' => $_GET['c']));Code: Select all
$rowcount = $pdo->query("SELECT id FROM products WHERE subid = '$s' AND pause = 'off'");
$num_rows = $rowcount->rowCount();Code: Select all
$query = "SELECT COUNT(id) AS numrows FROM products WHERE catid = :c AND pause = 'off'";
$result = $pdo->prepare($query);
$num_rows = $result->rowCount();
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);Code: Select all
$row = mysql_fetch_array($result, MYSQL_ASSOC);Code: Select all
$query = "SELECT id FROM products WHERE catid = :c AND pause = 'off'";
$stmt = $pdo->prepare($query);
$stmt->execute(array(':c' => $whatever_c_is_bound_to));
$numrows = $stmt->rowCount();Code: Select all
$query = "SELECT COUNT(id) AS numrows FROM products WHERE catid = :c AND pause = 'off'";
$stmt = $pdo->prepare($query);
$stmt->execute(array(':c' => $whatever_c_is_bound_to));
$numrows = $stmt->fetchColumn();Code: Select all
$query = "SELECT COUNT(id) AS numrows FROM products WHERE catid = :c AND pause = 'off'";
$result = $pdo->prepare($query);
$result->execute(array(':c' => $_GET['c']));
$numrows = $result->rowCount();
echo "$numrows";
$maxPage = ceil($numrows/$rowsPerPage);
$categ = "$cname";
$findcateg ="/ /";
$replacecateg ="-";
$categreplace = preg_replace ($findcateg, $replacecateg, $categ);
// 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'>[Anterior]</a> ";
$first = " <a href=\"/categ/page/$catid/$categreplace/pagenum=1\" class='bodylink'>[Primera Página]</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'>[Siguiente]</a>";
$last = " <a href=\"/categ/page/$catid/$categreplace/$maxPage\" class='bodylink'>[Última]</a>";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
// print the navigation link
echo "<div class='navpages'>" . $first . $prev . $nav . $next . $last . "</div>";