SQL Select Statement Command on PHP/MySQL

A

Anonymous

Guest
I have 3 drop down menu namely DEPARTMENT, FEEDBACK and NAMES
DEPARTMENT Tables consist of (ALL, IT, Finance, HR, Marketing) FEEDBACK Table (ALL,Survey, Inquiry, Complain, Others) NAMES Table(ALL,Individual List of Name of Employees). My Problem is that how can I make a SELECT Statement if they choose ALL in DEPARTMENT, FEEDBACK = Finance and NAMES = Cristine ? or DEPARTMENT = ALL , FEEDBACK = ALL and Name = Cristine. Please help me to built a SELECT Statement.

This is my select statement but it does not get a result if the they select ALL in the dropdown menu ..

$strSQL="SELECT feedback.trans_num as transnum,concat(users.lastname,' , ',users.firstname) as name,lkup_feedback.feed_desc,lkup_department.dept_desc,feedback.remarks,Date_Format(feedback.entry_date,'%Y-%m-%d %H:%m:%s'),lkup_status.stat_desc,feedback.status_remarks FROM feedback inner join users on users.password = feedback.emp_idno inner join lkup_feedback on lkup_feedback.feed_code = feedback.feedback inner join lkup_department on lkup_department.dept_code=feedback.department inner join lkup_status on lkup_status.stat_code=feedback.status WHERE feedback.emp_idno='".$_POST["employee"]."' and feedback.department='".$_POST["department"]."' and feedback.feedback='".$_POST["afeedback"]."' order by $order";

THIS IS MY DROPDOWN MENU FOR DEPARTMENT
<td style="font-size:10px"> Department </td>
<td>
<?php
$sql= "Select dept_code,dept_desc from lkup_department order by dept_code";
$result = mysql_query($sql);
$department=array();
while($row =mysql_fetch_array($result,MYSQL_NUM))
{
$department[$row[0]]=$row[1];
}
print "<select name=\"department\" class=\"login-textbox\" style=\"width:350px;\" onchange=\"javascript:Disable_Enable();\" ><option value = \"ALL\">ALL</option>";
foreach($department as $key=>$value)
{
if(isset($_POST["department"]) && $_POST["department"]==$key)
print "<option value=\"".$key."\" selected=\"selected\">".$value."</option>\r\n";
else
print "<option value=\"".$key."\">".$value."</option>\r\n";
}
?>

Thanks
 
heri said:
My Problem is that how can I make a SELECT Statement if they choose ALL in DEPARTMENT, FEEDBACK = Finance and NAMES = Cristine ? or DEPARTMENT = ALL , FEEDBACK = ALL and Name = Cristine. Please help me to built a SELECT Statement.

Code:
SELECT columns FROM department WHERE feedback = 'Finance' AND name = 'Christine';

SELECT columns FROM department WHERE feedback = 'ALL' AND name = 'Christine';
 
Thanks for your reply. But my problem is that how can i make a select Statment in case they choose DEPARTMENT = ALL, FEEDBACK = ALL, EMPLOYEE NAME = ALL or DEPARTMET = Finance, FEEDBACK = ALL, EMPLOYEE NAME = Christine I just need one Select Statement to Determine the right output or querry
 
Back
Top