I have written a query that outputs records from a MySQL database when the user selects an option. However, if no option is selected all records in the database table are returned. How do I insert a break in the code that will tell the user to select an option and stop this happening? My code is as follows;
$whereclause = $where1;
if ($whereclause == "") {
$whereclause = $where2;
} else if ($where2 == " ") {
$whereclause = $where3;
} else if ($where3 == " ") {
$whereclause = $where4;
} if($whereclause != "") {
$whereclause = " WHERE " . $whereclause;
}
$sql = "SELECT name, County, sector, company_size
FROM beacon
$whereclause";
$result = mysql_query($sql) or die("Error");