jamesxg1 Posted September 17, 2009 Share Posted September 17, 2009 Hiya guy's, Been a while since iv been on here, how's it hanging round here then ?, I have a really complicated query. <select id="open" name="open" class="element select medium"> <option value="9:00" >9:00 AM</option> <option value="10:00" >10:00 AM</option> <option value="11:00" >11:00 AM</option> <option value="12:00" >12:00 AM</option> <option value="1:00" >1:00 PM</option> <option value="2:00" >2:00 PM</option> <option value="3:00" >3:00 PM</option> <option value="4:00" >4:00 PM</option> <option value="5:00" >5:00 PM</option> <option value="6:00" >6:00 PM</option> <option value="7:00" >7:00 PM</option> <option value="8:00" >8:00 PM</option> <option value="9:00" >9:00 PM</option> <option value="10:00" >10:00 PM</option> </select> <label class="description" for="element_3_7"><small>Open Shop At</small></label> </div> <div class="right"> <select id="close" name="close" class="element select medium"> <option value="1:00" >1:00 PM</option> <option value="2:00" >2:00 PM</option> <option value="3:00" >3:00 PM</option> <option value="4:00" >4:00 PM</option> <option value="5:00" >5:00 PM</option> <option value="6:00" >6:00 PM</option> <option value="7:00" >7:00 PM</option> <option value="8:00" >8:00 PM</option> <option value="9:00" >9:00 PM</option> <option value="10:00" >10:00 PM</option> <option value="11:00" >11:00 PM</option> <option value="12:00" >12:00 PM</option> <option value="1:00" >1:00 AM</option> </select> <label class="description" for="element_3_8"><small>Close Shop At</small> </label> </div> <div class="left"> <select id="sdtime" name="sdtime" class="element select medium"> <option value="1:00" >1:00 PM</option> <option value="2:00" >2:00 PM</option> <option value="3:00" >3:00 PM</option> <option value="4:00" >4:00 PM</option> <option value="5:00" >5:00 PM</option> <option value="6:00" >6:00 PM</option> <option value="7:00" >7:00 PM</option> <option value="8:00" >8:00 PM</option> <option value="9:00" >9:00 PM</option> <option value="10:00" >10:00 PM</option> <option value="11:00" >11:00 PM</option> <option value="12:00" >12:00 PM</option> </select> <label class="description" for="element_3_"><small>Delivery Start Time</small></label> </div> <div class="right"> <select id="stdtime" name="stdtime" class="element select medium"> <option value="1:00" >1:00 PM</option> <option value="2:00" >2:00 PM</option> <option value="3:00" >3:00 PM</option> <option value="4:00" >4:00 PM</option> <option value="5:00" >5:00 PM</option> <option value="6:00" >6:00 PM</option> <option value="7:00" >7:00 PM</option> <option value="8:00" >8:00 PM</option> <option value="9:00" >9:00 PM</option> <option value="10:00" >10:00 PM</option> <option value="11:00" >11:00 PM</option> <option value="12:00" >12:00 PM</option> <option value="1:00" >1:00 AM</option> <option value="2:00" >2:00 AM</option> <option value="3:00" >3:00 AM</option> </select> Them select boxes consist of four things, Shop open time, Shop close time, Delivery start time, Delivery end time, I need it so that i can i can do the following, Shop open time > Shop close time = ERROR Shop open time < Shop close time = Continue Delivery start time > Delivery start time = ERROR Delivery end time < Delivery end time = Continue Shop open time > Delivery start time = ERROR Shop open time < Delivery start time = Continue Ect ect, What do i do here to accomplish this ?, Many many thanks, James. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted September 17, 2009 Author Share Posted September 17, 2009 This is begging to become a nightmare can anyone help ?, Many thanks, James. Quote Link to comment Share on other sites More sharing options...
corbin Posted September 17, 2009 Share Posted September 17, 2009 I would do the hours as a 24 hour value. 0, 1, ..., 12, 13, ..., 23 Then you can just compare the numbers as you would compare any numbers. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted September 18, 2009 Author Share Posted September 18, 2009 Sound like you have the solution there mate , Would you give me a sample of what you mean ?, Bare in mind the time's selected by the user will be put into a mysql , Many thanks, James. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted September 18, 2009 Author Share Posted September 18, 2009 Bump. Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted September 18, 2009 Author Share Posted September 18, 2009 Bump. Quote Link to comment Share on other sites More sharing options...
zq29 Posted September 18, 2009 Share Posted September 18, 2009 Something like this? $continue = true; if(($shop_open > $shop_close) || ($del_start > $del_end) || ($shop_open > $del_start)) $continue = false; if($continue) { //continue } else { //error } Quote Link to comment Share on other sites More sharing options...
YourNameHere Posted September 18, 2009 Share Posted September 18, 2009 Imagin this: instead of the option values being "3:00" and so on. I would be just a number. <select id="open" name="open" class="element select medium"> <option value="9" >9:00 AM</option> <option value="10" >10:00 AM</option> <option value="11" >11:00 AM</option> <option value="12" >12:00 AM</option> <option value="13" >1:00 PM</option> <option value="14" >2:00 PM</option> <option value="15" >3:00 PM</option> <option value="16" >4:00 PM</option> <option value="17" >5:00 PM</option> <option value="18" >6:00 PM</option> <option value="19" >7:00 PM</option> <option value="20" >8:00 PM</option> <option value="21" >9:00 PM</option> <option value="22" >10:00 PM</option> </select> So then the SQL query would just be a simple comparison. What would be stored in the DB would just be numbers. like: delStart => 11 delEnd => 14 then you could compare them by loading those numbers into vars. $delStart = $del->start; $delEnd = $del->end; then the math if ($delStart < $delEnd) { //Continue } else { //Error! } Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted September 19, 2009 Author Share Posted September 19, 2009 Imagin this: instead of the option values being "3:00" and so on. I would be just a number. <select id="open" name="open" class="element select medium"> <option value="9" >9:00 AM</option> <option value="10" >10:00 AM</option> <option value="11" >11:00 AM</option> <option value="12" >12:00 AM</option> <option value="13" >1:00 PM</option> <option value="14" >2:00 PM</option> <option value="15" >3:00 PM</option> <option value="16" >4:00 PM</option> <option value="17" >5:00 PM</option> <option value="18" >6:00 PM</option> <option value="19" >7:00 PM</option> <option value="20" >8:00 PM</option> <option value="21" >9:00 PM</option> <option value="22" >10:00 PM</option> </select> So then the SQL query would just be a simple comparison. What would be stored in the DB would just be numbers. like: delStart => 11 delEnd => 14 then you could compare them by loading those numbers into vars. $delStart = $del->start; $delEnd = $del->end; then the math if ($delStart < $delEnd) { //Continue } else { //Error! } Perfect!. Thanks dude. Many thanks, James. 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.