I can't figure out where I went wrong here. It returns no results and I know there are records when I go to
http://www.xxxxxxxx.com/family/recipes/catagories1.php?Catagory=Pies it returns 0
/**
* This is our paging options
*/
$_per_page = 2;
$_numeric_index = true;
$_url_param = 'page';
$_cur_page = isset($_GET[$_url_param]) ? $_GET[$_url_param] : 1; // default on first page
try {
$conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
} catch (PDOException $e) {
die('Connection failed: ' . $e->getMessage());
}
$query = "SELECT * FROM recipes WHERE Catagory = :Catagory";
$prepped = $conn->prepare($query);
$prepped->execute(
array(
':Catagory' => $Catagory
));
echo "<p>There are (" . $prepped->rowCount() . ") records in the database.</p>";
echo "<p>We will show (" . $_per_page . ") per page.</p>";
if ($prepped->rowCount() > $_per_page) {
// do some match for our low and total pages
$_low_limit = $_per_page * ($_cur_page - 1);
$_total_pages = ceil($prepped->rowCount() / $_per_page);
// modify the query to limit
$query .= " LIMIT " . $_low_limit . "," . $_per_page;
// re prepare and execute the query
$prepped = $conn->prepare($query);
$prepped->execute(
array(
':Catagory' => $Catagory
));
// now we compile our paging HTML
$_paging_html = '<div class="paging"><h3>';
$_url = $_SERVER['SCRIPT_NAME'] . '?';
// if we have arguments in the URL already we need to preserve them
if (preg_match('/[^\/\?](.*)$/', $_SERVER['QUERY_STRING'], $params)) {
$_url .= $params[0];
// if our paging param is there remove it
$_url = preg_replace('/&' . $_url_param . '=[\d]/', '', $_url);
}
$_link = '<a href="' . $_url . '&' . $_url_param . '=%s" target="_self">%s</a>';
// if we want a numeric index
if ($_numeric_index) {
// now the rest of the pages
for ($i=1; $i<=$_total_pages; $i++) {
// if it's the current page we don't show it
if ($_cur_page == $i) continue;
$_paging_html .= sprintf($_link, $i, $i) . " .. ";
}
} else {
// we just want next and prev buttons
if (($_cur_page - 1) > 0) {
$_paging_html .= sprintf($_link, ($_cur_page - 1), '<- Prev') . "..";
}
if (($_cur_page + 1) <= $_total_pages) {
$_paging_html .= sprintf($_link, ($_cur_page + 1), 'Next ->');
}
}
// both ways we show a 'legend'
$_paging_html .= " Page (" . $_cur_page . ") of (" . $_total_pages . ")";
// close our div
$_paging_html .= "<h/3></div>";
}
echo isset($_paging_html) ? $_paging_html : '';
echo "<table border='1' cellpadding='4' width='810' align='center'>";
echo "<tr><th width=\"20\">ID</th><th width=\"100\">Date</th><th width=\"50\">Catagory</th><th width=\"100\">Title</th><th width=\"100\">Photo</th><th width=\"240\">Details</th><th width=\"60\">Full Record</th><th width=\"80\">Add Photos</th><th width=\"30\">Edit</th><th width=\"30\">Delete</th></tr>";
while ($row = $prepped->fetch(PDO::FETCH_OBJ)) {
$folder = $row->Catagory;
$path = "/home/xxxxxxx/public_html/family/recipes/images/".$folder;
// display data in table
echo "<tr>";
echo "<td width=\"20\" align=\"center\">$row->Id</td>";
echo "<td width=\"100\" align=\"center\"> $row->Date</td>";
echo "<td width=\"50\" align=\"center\"> $row->Catagory</td>";
echo "<td width=\"100\" align=\"center\"> $row->Title</td>";
echo"<td width=\"100\" align=\"center\"><img src=\"http://www.xxxxxxxxx.com/family/recipes/images/$folder/$row->photo\" width=\"90\" height=\"90\"></td>";
echo "<td width=\"240\"> $row->Details</td>";
echo "<td width=\"60\" align=\"center\"><a href=\"recipesdetails.php?Id=$row->Id\">View</a></td>";
echo "<td width=\"80\" align=\"center\"><p><a href=\"http://www.xxxxxxxxx.com/family/recipes/admin/replacephoto.php?Id=$row->Id\" onclick=\"return confirm('This will DELETE the Primary Photo. There will be NO Photo on the View Page unless you upload a new one. Are you sure you want to delete this photo?');\">Replace Photo</a></p>";
echo "<p><a href=\"multiphotos.php?Id=$row->Id\">Add A Photo</a></p>";
echo "<p><a href=\"deleterecipes.php?Id=$row->Id&Catagory=$row->Catagory\">Delete Photos</a></p></td>";
echo "<td width=\"30\" align=\"center\"><a href=\"recipesedit.php?Id=$row->Id\">Edit</a></td>";
echo "<td width=\"30\" align=\"center\"><a href=\"deleterecipes.php?Id=$row->Id&Catagory=$row->Catagory\">Delete</a></td>";
echo "</tr>";
}
echo "</table><p>";
echo isset($_paging_html) ? $_paging_html : '';
Any Ideas would be appreciated thanks