Steve Karuma Steve Karuma - 3 months ago 11
PHP Question

I need to know how to use the AND in mysqli statements while considering multiple paramters

The following is what i use but it doesn't return any results. Maybe i have the syntax wrong.

<?php
$item_id = $_GET['id'];
$item_color = $_GET['color'];
$sql = "SELECT * FROM items WHERE item_id = $item_id AND item_color = '$item_color'";
$query = mysqli_query($db, $sql);
?>

Answer

Using string concatenation where you add variables.

 $sql = "SELECT * FROM items WHERE item_id =". $item_id." AND item_color ='". $item_color."'";
Comments