如何使用SELECT和RADIO一起显示数据
I am working on a module where admin can see list of users, i.e. Unapproved, approved and all users in list. I have added a functionality in which a select dropdown is provided and it lists batch numbers from database. Now when admin selects a batch number from drop down and then selects one of the three radios, i.e. Approved, Unapproved and All the list must come based on batch number selected. Till now what I have done is getting the list of users based on radios only. I need to implement this with batch number too so that the admin first selects the batch number from dropdown and then selects the desired radio to see the listings. How can this be implemented? I am posting my code for this and any insight or help will be really helpful.
<form action="" method="POST">
<div class="col-md-6">
<div class="col-md-4">
<label for="username" class="control-label">Batch No. :
</label>
</div>
<div class="col-md-8">
<select name="batchnumber" class="form-control" required id="batchno" >
<option value="">select batch number
</option>
<?php
$sql = mysql_query("SELECT DISTINCT rpp_regn_bulkbatch_no,rpp_id FROM tbl_regn_prescribed_parameters where rpp_regn_bulkbatch_no != 0");
while ($row = mysql_fetch_assoc($sql)){
echo "<option value=" . $row['id'] . ">" . $row['rpp_regn_bulkbatch_no'] . "</option>";
}
?>
</select>
</div>
</div>
<input type='radio' name='users' value='unapproved' checked /> Unapproved Candidates
<input type='radio' name='users' value='approved' /> Approved Candidates
<input type='radio' id='show' name='users' value='all' /> All Candidates
<input type="submit" value="View Candidates" id="submit" class="btn btn-success">
And for PHP,
if((isset($_POST['users'])) && (isset($_POST['batchnumber'])) ){
$users=$_POST['users'];
$batchnumber= $_POST['batchnumber'];
}else{
$users='';
$batchnumber='';
}
switch ($users)
{
case "all":
$sqlQuery = "SELECT * FROM tbl_user WHERE type =3 ";
break;
case "approved":
$sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND status =1"; break;
case "unapproved":
$sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND status =0";
break;
}
It should go like,
if (isset($_POST['submit1'])) {
if(isset($_POST['batchnumber'])) {
$selected = $_POST['batchnumber'];
}else { echo "empty.";$selected='';}
if(isset($_POST['users'])){
$users=$_POST['users'];
}else{
$users='';
}
switch ($users)
{
case "all":
$sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND bulk_batch_number= '$selected' ";
break;
case "approved":
$sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND status =1
break;
case "unapproved":
$sqlQuery = "SELECT * FROM tbl_user WHERE type =3 AND status =0 AND bulk_batch_number= '$selected'"; break;
} }
?>