Originally posted by ali_p
//division is the name of the field with the multiple select box
if (isset($_POST['division']) && is_array($_POST['division'])) {
foreach ($_POST['division'] as $value) {
// to print out what divisions were selected
echo "value: $value<br>\n";
}
}
//$value is what i base the query on
$sql = " SELECT * FROM jobs WHERE division = '$value'";
[/b]
By this stage, $value is the last element in the $POST['division'] array. You never do anything with the rest except echo them in that loop.
$divisions = $_POST['division'];
foreach($divisions as $k=>$division)
{
$divisions[$k] = "division='$division'";
}
$search_conditions = join(' OR ', $divisions);
$query = "select
title, ref_no, location, salary, job_id
from
jobs";
if($search_conditions!='')
$query .= " where ".$search_conditions;
And you should check those $divisions to make sure someone's not trying to crack your site.