I was attempting to use the following if/else statements to build a query, but I'm having a problem evaluating for NULL in the first step.
After some searching online, I can't seem to track down what I'm doing wrong... should I be using empty quotes instead: ""
?
That also gave me an error, though.
So I don't know if the problem is in the first block or the second, which is the while
loop.
Any suggestions?
$name = $_POST['Your_name'];
if ($location != "All" && $name == NULL) $query="SELECT * FROM talent WHERE duty_station='$location')";
else if($location == "All" && $name != "All" ) $query="SELECT * FROM talent WHERE Your_name IN ('$name')";
else if($dutyReq != "All" && $name == "All" ) $query="SELECT * FROM talent WHERE duty_station='$location'";
else if($location == "All" || $name == "All" ) $query="SELECT * FROM talent";
Then my loop to print out the data gives me this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/talent/searchresults.php on line 64
This is the code that the error comes from:
$result=mysql_query($query);
mysql_query($result);
echo "<table border='1'>
<tr>
<th>Your name</th>
<th>duty station</th>
<th>first proficiency</th>
</tr>";
while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['Your_name'] . "</td>";
echo "<td>" . $row['duty_station'] . "</td>";
echo "<td>" . $row['prof_order_processing'] . "</td>";
echo "</tr>";
}
echo "</table>";