Updated version of your code to put out an error message on the query if there is one. Also sanitises the input
if (is_array($_POST['select']))
{
$c = array_map('array_map_callback', $_POST['select']);
$result = mysqli_query($con, 'SELECT item_name, item_number FROM item WHERE item_number IN ("'.implode('","', $c).'")') OR die(mysqli_error($con));
echo "
item name
item number
";
while($row = mysqli_fetch_array($result))
{
echo "";
echo "" . $row['item_name'] . " ";
echo "" . $row['item_number'] . " ";
echo " ";
}
echo "
";
mysqli_close($con);
}
else
{
echo "No items selected";
}
function array_map_callback($a)
{
global $con;
return mysqli_real_escape_string($con, $a);
}
?>
Hopefully this should put out the message of what is wrong with the query.
No comments:
Post a Comment