// Escape the parameters
$category_id_esc = $db->escape_string($category_id);
// Execute the statement - manually add single quotes around parameters
$query = "SELECT * FROM products WHERE categoryID = '$category_id_esc'";
$result = $db->query($query);
// Check the result set
if ($result == false) {
$error_message = $db->error;
echo("An error occurred: $error_message");
exit;
}
// Get the number of rows in the result set
$row_count = $result->num_rows;
<?php
for ($i = 0; $i < $row_count; $i++) :
$product = $result->fetch_assoc();
?>
<tr>
<td><?php echo $product['productID']; ?></td>
<td><?php echo $product['categoryID']; ?></td>
<td><?php echo $product['productName']; ?></td>
<td><?php echo $product['productCode']; ?></td>
<td><?php echo $product['listPrice']; ?></td>
</tr>