This question already has an answer here:
I have a page where a user can select multiple check boxes and then submit the form, on the next page it displays what they checked with more details. but my query is not working. how can i pass the checkbox data to the mysql query to get the rest of the data.
this is my query:
$c=$_POST['select'];
$result=mysqli_query($con, 'SELECT * FROM item WHERE item_number IN ("'.implode('","', $c).'")');
echo "<table border='1'>
<tr>
<th>item name</th>
<th>item number</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['item_name'] . "</td>";
echo "<td>" . $row['item_number'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
when running the query i get this error:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
it returns no results but if i echo the query and copy paste into mysql i get the results, but when running from PHP i get only the error.
any help would be greatly appreciated