i have a function which accept an array which i want to breakdown and pass into where condition. My Function
<?php
function somearray($value = array())
{
$conditions = "";
foreach($value as $key => $condition)
{
$conditions .= "$key=$condition && ";
}
$conditions = substr($conditions, 0, -4);
$qry = mysql_query("SELECT * FROM maincase WHERE $conditions");
while($arr = mysql_fetch_array($qry))
{
echo 'Ticket Number= '.$arr['ticket_number'].'<br />';
}
}
?>
i want to send values through a form, but only the selected checkbox
<?php
if(isset($_GET['filter']))
{
$list = array(
"region" => $_GET['region'],
"status" => $_GET['status']
);
somearray($list);
}
?>
<form action="" class="form-inline" method="get">
<label for="">Region</label>
<input type="checkbox" name="region" <?php if(isset($_GET['region'])) { echo 'checked' ;} ?> value="1">
<label for="">Status</label>
<input type="checkbox" name="status" <?php if(isset($_GET['status'])) { echo 'checked' ;} ?> value="3">
<input type="submit" value="filter" name="filter">
</form>
this code works. But i have to filter 7 to 8 fields. I want to send the values only if the checkbox is checked.