$_GET variable Array with MySQL Query

I am having trouble figuring out how to work an if statement into my PHP containing a MySQL Query. Here’s what I have so far (it’s unfinished):

$industry = $_GET['industry'];
$location = $_GET['location'];
$position = $_GET['position'];
$region = $_GET['region'];

if($industry=="any"){

}

if($location=="any"){

}

if($position=="any"){

}

if($region=="any"){

}

$sql_cat = "
SELECT *
FROM jobs
WHERE industry_cat='$industry' && location_cat='$location' && position_cat='$position' && region_cat='$region'
ORDER BY id DESC
";
$result_cat = $mysqli->query($sql_cat);
$num_rows_cat = mysqli_num_rows($result_cat);

Basically, what I’m trying to say is that if any of the variables are set to ‘any’ then I want those variables to represent all the possibilities (there’s like five possibilites in the form for each variable). I figured I’d use arrays in the where clause (like WHERE industry IN ($industry)) but then it wouldn’t work if someone actually did pick a variable.

I may be a little off track but am having trouble wrapping my mind around it. Any help would be greatly appreciated. Thanks!

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories