I am converting old-style MySQL/PHP queries on a site. I have a page that has a series of checkboxes. This is submitted, and a query is built based on what checkboxes are checked (there are at least 6 like the following):
if (xxxxx) {
$furthersort=$furthersort."AND age_birth='yes' ";
}
if (xxxxx) {
$furthersort=$furthersort."AND age_three='yes' ";
}
...
$prequery = "SELECT id from products WHERE product_categories LIKE '%$catid%' ".$furthersort."ORDER BY product_name ASC";
I'm trying to move the second part this over to PHP like this:
$query = $objDb->prepare("SELECT id from products WHERE product_categories LIKE ? ? ORDER BY product_name ASC");
$params3 = array('%$catid%',$furthersort);
$query->execute($params3);
while ($row = $query->fetch(PDO::FETCH_ASSOC));
But it's not working. The variables created by the if's are correct, so I'm sure it's because I am missing an understanding of how the prepare portion interprets the information, but I need a push in the right direction.