<select name="criteria" class="report_listbox">
<option value="">Status</option>
<option value="PASS">PASS</option>
<option value="FAIL">FAIL</option>
<option value="ALL">ALL</option>
</select>
------------------------------------------------------------------------------------
$date = $_POST;
$criteria = $_POST;

$sql=" SELECT frsemployees.`name`, bft.`date`,bft.`dpush`,bft.`push`,
bft.`dsit`,bft.`sit`,bft.`drun`,bft.`run`,bft.`status`
FROM `bft`
INNER JOIN frsemployees ON frsemployees .empid = bft.empid
WHERE bft.`date`= '".$date."' AND bft.`status` = '".$criteria."' ";
--------------------------------------------------------------------------------------
the bft database table `status` row containes "FAIL" or "PASS". now when i select "PASS" and "FAIL im getting all the people who passes and failed... how can i modifie the query so that when i click "ALL" in the dropdown list box and get all "PASS" and "FAIL"

Recommended Answers

All 6 Replies

Member Avatar for diafol

Just leave off the criteria bit from the where clause

commented: helpful Post +6

Just leave off the criteria bit from the where clause

Then i wont get "PASS" and "FAIL" employees... the criteria includes "PASS" "FAIL" and "ALL"

$date = $_POST['date'];
$criteria = $_POST['criteria'];
$join="";
if($criteria=="PASS" || $criteria=="FAIL" )
{
$join=" AND bft.`status` = '".$criteria."'";
}
$sql=" SELECT frsemployees.`name`, bft.`date`,bft.`dpush`,bft.`push`,
bft.`dsit`,bft.`sit`,bft.`drun`,bft.`run`,bft.`status`
FROM `bft`
INNER JOIN frsemployees ON frsemployees .empid = bft.empid
WHERE bft.`date`= '".$date." $join";
Member Avatar for diafol

AS KP puts it, you just leave off the status part when ALL is the criteria.

AS KP puts it, you just leave off the status part when ALL is the criteria.

Thank you both of you.. it really helped me...thanks again

Mark as solved if your problem was solved.
use code tags for your codes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.