karenn1 Posted October 19, 2007 Share Posted October 19, 2007 I have three dropdowns on my page that filters a search. I have four if statements to determine whether a value was selected in the dropdown. Independatly, all four of them work on their own but as soon as I place them all on the same page, any search I do just returns all results. My code below: // Region = All, Rep = All, Outlet = All if (($_REQUEST['areas'] = 'All') && ($_REQUEST['reps'] = 'All') && ($_REQUEST['outlets'] = 'All')) { $sql_prop = "SELECT Venue_Region, CONCAT(TMR_Name, ' ', TMR_Surname) AS Name,Venue_Name, SUM(Quantity) AS Quantity, SUM(Value_Cost) AS Income FROM web_summary_info WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' GROUP BY Venue_Region,(TMR_Name + ' ' + TMR_Surname), Venue_Name"; $result_prop = mysql_query($sql_prop); } // Region = Selected, Rep = All, Outlet = All if (($_REQUEST['areas'] != 'All') && ($_REQUEST['reps'] = 'All') && ($_REQUEST['outlets'] = 'All')) { $areas = $_REQUEST['areas']; $sql_prop = "SELECT Venue_Region, CONCAT(TMR_Name, ' ', TMR_Surname) AS Name,Venue_Name, SUM(Quantity) AS Quantity, SUM(Value_Cost) AS Income FROM web_summary_info WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' AND Venue_Region = '".$areas."' GROUP BY Venue_Region,(TMR_Name + ' ' + TMR_Surname), Venue_Name"; $result_prop = mysql_query($sql_prop); } // Region = Selected, Rep = Selected, Outlet = All if (($_REQUEST['areas'] != 'All') && ($_REQUEST['reps'] != 'All') && ($_REQUEST['outlets'] = 'All')) { //$name = $_POST['Name']; $areas = $_REQUEST['areas']; $reps = $_REQUEST['reps']; $sql_prop = "SELECT Venue_Region, CONCAT(TMR_Name, ' ', TMR_Surname) AS Name, Venue_Name, SUM(Quantity) AS Quantity, SUM(Value_Cost) AS Income FROM web_summary_info WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' AND Venue_Region = '".$areas."' AND TMR_Code = '".$reps."' GROUP BY Venue_Region,(TMR_Name + ' ' + TMR_Surname), Venue_Name"; $result_prop = mysql_query($sql_prop); } // Region = Selected, Rep = Selected, Outlet = All if (($_REQUEST['areas'] != 'All') && ($_REQUEST['reps'] != 'All') && ($_REQUEST['outlets'] != 'All')) { //$name = $_POST['Name']; $areas = $_REQUEST['areas']; $reps = $_REQUEST['reps']; $outlets = $_REQUEST['outlets']; $sql_prop = "SELECT Venue_Region, CONCAT(TMR_Name, ' ', TMR_Surname) AS Name, Venue_Name, SUM(Quantity) AS Quantity, SUM(Value_Cost) AS Income FROM web_summary_info WHERE Trans_Date BETWEEN '".$from_date."' AND '".$to_date."' AND Venue_Region = '".$areas."' AND TMR_Code = '".$reps."' AND Venue_ID = '".$outlets."' GROUP BY Venue_Region,(TMR_Name + ' ' + TMR_Surname), Venue_Name"; $result_prop = mysql_query($sql_prop); } Like I said, independantly it works great but I need it combined. My dropdowns look as follows: <select name="areas" id="areas" onchange="window.document.searchform.submit();"> <option value="All" selected="selected">Select First</option> <?php while ($rs_dd1 = mysql_fetch_array($result_dd1)) { print "<option value=\"".$rs_dd1["Venue_Region"]."\">".ucwords($rs_dd1["Venue_Region"])."</option>"; } ?> </select> <select name="reps" id="reps" onchange="window.document.searchform.submit();"> <option value="All" selected="selected">Select Second</option> <?php while ($rs_dd2 = mysql_fetch_array($result_dd2)) { print "<option value=\"".$rs_dd2["TMR_Code"]."\">".ucwords($rs_dd2["Name"])."</option>"; } ?> </select> <select name="outlets" id="outlets"> <option value="All" selected="selected">Select Third</option> <?php while ($rs_dd3 = mysql_fetch_array($result_dd3)) { print "<option value=\"".$rs_dd3["Venue_ID"]."\">".ucwords($rs_dd3["Venue_Name"])."</option>"; } ?> </select> I know I've been a bit of a nuisance on these forums but can anybody help? Thanks, Karen Quote Link to comment Share on other sites More sharing options...
steve448 Posted October 19, 2007 Share Posted October 19, 2007 You need to use 2 equals if your evaluating that both sides are the same as each other So this: if (($_REQUEST['areas'] = 'All') && ($_REQUEST['reps'] = 'All') && ($_REQUEST['outlets'] = 'All')) Becomes: if (($_REQUEST['areas'] == 'All') && ($_REQUEST['reps'] == 'All') && ($_REQUEST['outlets'] == 'All')) Quote Link to comment Share on other sites More sharing options...
karenn1 Posted October 19, 2007 Author Share Posted October 19, 2007 Steve448 for president!!!! Works like a charm. Thank you!!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.