So basicly this is my code:
echo "<SELECT>";
foreach($arr_res as $op) {
$q3 = mysql_query(mysql_fetch_array("SELECT SL_TIME FROM SLOTS WHERE SL_ID='$op'"));
echo "<OPTION value=".$op.">".$q3."</OPTION>";
}
echo "</SELECT>";
$arr_res is the resulting array of an array_diff. It has only numerical values which are the SL_ID from my timeslots.. I want to show SL_TIME but the result I get is the $q3 producing empty result.. Why isn’t this working?
You don’t query mysql_fetch_array. Mysql_query gives an result on wich you use mysql_fetch_array. So the correct code would be:
However, $q3 will be an array, which is probably not what you want. In addition it would be a lot better if use an abstraction such as PDO (http://www.php.net/manual/en/class.pdo.php). This will maximize performance and increase the security.