DarkWater Posted November 8, 2008 Share Posted November 8, 2008 Erm, yes and no. You need to actually make sure that $_GET['validmenu'] exists before trying to use it in implode(). Quote Link to comment Share on other sites More sharing options...
Zergman Posted November 8, 2008 Author Share Posted November 8, 2008 Again, sorry for being a complete newb on this stuff. So if I understand you right, It would be best to put the code in my page after the select box? EDIT: tried that, no change. Reading your notes again, I think you mean the VALUE has to exist in $valid before implode comes into play which is why it errors until data is put in and the query is submitted ..... i think Quote Link to comment Share on other sites More sharing options...
Zergman Posted November 8, 2008 Author Share Posted November 8, 2008 Been trying to figure out how to make $_GET['validmenu'] exist before trying to use it in implode() but for the life of me, can't. Suggestions? Quote Link to comment Share on other sites More sharing options...
flyhoney Posted November 10, 2008 Share Posted November 10, 2008 You just need to do something like: <?php if (isset($_GET['name_of_submit_button'])) { $orderedby = $_GET['sortby']; $lvl2display = $_GET['lvl2']; $startdate = $_GET['startdatefield']; $enddate = $_GET['enddatefield']; $t2agent = $_GET['nsagentfield']; $flagent = $_GET['frontlineagentfield']; $conclusion = $_GET['conclusionmenu']; $conclusioncomments = $_GET['conclusioncomments']; $prov = $_GET['radio']; $CBBC = $_GET['BC']; $valid = $_GET['validmenu']; $level1 = $_GET['country']; $level2 = $_GET['state']; $level3 = $_GET['city']; $notes = $_GET['notesfield']; $comma_separated = implode(",", $_GET['validmenu']); echo $comma_separated; } ?> If you try to access $_GET, but the form has not been submitted (like on a blank page load), then $_GET is undefined and will give you errors. Quote Link to comment Share on other sites More sharing options...
Zergman Posted November 10, 2008 Author Share Posted November 10, 2008 Awesome, thanks flyhoney! Just one last problem with all this and I think it should be good to go. When I put in that code flyhoney, I am now getting a sql syntax error. Pardon my newbish sql statment SELECT * FROM `data` WHERE tdate between '$startdate%' and '$enddate%' AND t2agent LIKE '$t2agent%' AND flagentTID LIKE '$flagent%' AND resolution LIKE '$conclusion%' AND rescomments LIKE '$conclusioncomments%' AND prov LIKE '$prov%' AND valid IN ($comma_separated) AND level1 LIKE '$level1%' AND level2 LIKE '$level2%' AND level3 LIKE '$level3%' AND notes LIKE '$notes%' ORDER BY tdate says its dealing with my "valid IN ($comma_separated)" part. Quote Link to comment Share on other sites More sharing options...
flyhoney Posted November 10, 2008 Share Posted November 10, 2008 Can you post an example of the complete query? If $comma_separated is an empty string you might have to set $comma_separated = "''" to make the query valid. Maybe something like this: <?php if (isset($_GET['validmenu'])) { $comma_separated = implode("','", $_GET['validmenu']); } else { $comma_separated = "''"; // or maybe some default value, like "'default'" } ?> Quote Link to comment Share on other sites More sharing options...
Zergman Posted November 10, 2008 Author Share Posted November 10, 2008 Wicked, that got rid of the error nicely flyhoney! Only thing now LOL. .... it never ends with me .... is that my default doesn't work. Im assuming this is 100% due to my ability to write poor code. In my select box, I have sorta a default selection. This is my box. <select name="validmenu[]" class="inputbox" id="validmenu" size="4" multiple> <option value="%" selected="selected">All</option> <option value="*Valid*">*Valid*</option> <option value="Behaviour">Behaviour</option> <option value="Improper Abstract">Improper Abstract</option> <option value="Improper Route">Improper Route</option> <option value="Invalid STN">Invalid STN</option> <option value="Kudos">Kudos</option> <option value="Other">Other</option> <option value="Policy/Procedure">Policy/Procedure</option> <option value="Poor Ticket Creation">Poor Ticket Creation</option> <option value="Troubleshooting">Troubleshooting</option> </select> When All is selected, the query won't go. Only when other options are selected. What would be best to use with IN() to make it search all? the query looks like this when All is selected which won't work valid IN ('%') Quote Link to comment Share on other sites More sharing options...
premiso Posted November 10, 2008 Share Posted November 10, 2008 You cannot use IN() to search for all, you need to use the LIKE operator: IE: valid LIKE '%' Should pull up all values of valid. Quote Link to comment Share on other sites More sharing options...
Zergman Posted November 10, 2008 Author Share Posted November 10, 2008 Ah, didn't know IN() couldn't do all. Good to know. Would it be better than to make my default a string of all options? Quote Link to comment Share on other sites More sharing options...
flyhoney Posted November 10, 2008 Share Posted November 10, 2008 Yeah that should work. Quote Link to comment Share on other sites More sharing options...
Zergman Posted November 10, 2008 Author Share Posted November 10, 2008 boo ya! seems perfect now. A big thanks to everyone for their help! Really appreciated 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.