The query below will be used a search script. For some reason it won\'t return all results where either condition is true. What am i doing wrong?
$sql = \"SELE
You are printing outside of while
. Which means, no matter how many results you have, only the one will be printed.
Either print inside the loop
while($row = mysql_fetch_array($query))
{
$name = htmlspecialchars($row['name']);
$code = htmlspecialchars($row['id_code']);
print("$code: $name
");
}
or collect the variables in an array while looping and use them after the loop as you like
$result_array = array();
while($row = mysql_fetch_array($query))
{
$name = htmlspecialchars($row['name']);
$code = htmlspecialchars($row['id_code']);
$result_array[] = array(
'name' => $name,
'code' => $code
);
}
print_r($result_array);