Hi guys this is my search script

I would have thought that ORDER BY would go after the WHERE statement but it didnt work

Any help on where it should go many thanks


PHP Code:
$query "SELECT *, date_format(startdate,'%d/%m/%Y') startdate FROM jobs WHERE 1=1 ";

if (!empty(
$category)) {
  
$query .= "AND category='$category' ";
}

if (!empty(
$location)) {
  
$query .= "AND location='$location' ";


if (!empty(
$salarytype)) {
  
$query .= "AND salarytype='$salarytype' ";
}

if (!empty(
$salary)) {
  
$query .= "AND salary >= $salary ";
}

if (!empty(
$jobstatus)) {
  
$query .= "AND jobstatus='$jobstatus' ";