irox Posted December 16, 2009 Share Posted December 16, 2009 hello, I wont select the record with the following conditions ... I have 4 fields with time opening and closing hours morning and afternoon hours opening and closing ... Time format: 24 hours egsemple mysql records (fields in the db I have tried set as varchar and as time): $monday_time1= '08:30'; // db record $monday_time2= '12:30'; // db record $monday_time3= '20:30'; // db record $monday_time4= '23:30'; // db record $k = 'close'; db record ------------------------------------my actual code: $idtime = "03:00"; //variable $sql1 = mysql_query("select * from dat where $k <> '1' and ($monday_time1 != 'k' and $monday_time1 <= '$idtime' and $monday_time2 >='$idtime') or ($monday_time3 <= '$idtime' and $monday_time4 >='$idtime')")or die ("Errore: ". mysql_error()); but this not work well... also select records that are not present at certain times... where i error ? sorry for my bad english .... Quote Link to comment https://forums.phpfreaks.com/topic/185348-select-beetween-2-times-help-please/ Share on other sites More sharing options...
Deoctor Posted December 16, 2009 Share Posted December 16, 2009 is it $monday_time1 != 'k' or $monday_time1 != '$k' Quote Link to comment https://forums.phpfreaks.com/topic/185348-select-beetween-2-times-help-please/#findComment-978462 Share on other sites More sharing options...
irox Posted December 16, 2009 Author Share Posted December 16, 2009 hi ym_chait ... $k = // is the day in the week of Closing , and if is not "1" there are close .... eg: $k = 'sunday_close'; // db field .... if record have "1" is close , else they must have an time eg: 20:00 i think 'k' is ok .... Quote Link to comment https://forums.phpfreaks.com/topic/185348-select-beetween-2-times-help-please/#findComment-978465 Share on other sites More sharing options...
Deoctor Posted December 16, 2009 Share Posted December 16, 2009 hello, I wont select the record with the following conditions ... Ihave 4 fields with time opening and closing hours morning and afternoonhours opening and closing ... Time format: 24 hours egsemple mysql records (fields in the db I have tried set as varchar and as time): $monday_time1= '08:30'; // db record $monday_time2= '12:30'; // db record $monday_time3= '20:30'; // db record $monday_time4= '23:30'; // db record $k = 'close'; db record ------------------------------------my actual code: $idtime = "03:00"; //variable $sql1= mysql_query("select * from dat where $k <> '1' and($monday_time1 != 'k' and $monday_time1 <= '$idtime' and$monday_time2 >='$idtime') or ($monday_time3 <= '$idtime' and$monday_time4 >='$idtime')")or die ("Errore: ". mysql_error()); but this not work well... also select records that are not present at certain times... where i error ? sorry for my bad english .... no i am saying as u have given as k in the query.. for the variables u should run as $k, i think that is wrong the query. Quote Link to comment https://forums.phpfreaks.com/topic/185348-select-beetween-2-times-help-please/#findComment-978473 Share on other sites More sharing options...
ignace Posted December 16, 2009 Share Posted December 16, 2009 What do you want to achieve with this code? Get the closing and opening hours of a store? +-----------+--------------------------------------------+ | day | opening_hours | +-----------+--------------------------------------------+ | Monday | 8.30 till 11.30 and 13.00 till 17.00 | | Tuesday | 8.30 till 11.30 and 13.00 till 17.00 | | Wednesday | 8.30 till 11.30 and 13.00 till 17.00 | | Thursday | 8.30 till 11.30 and 13.00 till 17.00 | | Friday | 8.30 till 11.30 and 13.00 till 17.00 | | Saturday | 8.30 till 11.30 | +-----------+--------------------------------------------+ Keep it simple let the user define the closing and opening hours. Quote Link to comment https://forums.phpfreaks.com/topic/185348-select-beetween-2-times-help-please/#findComment-978496 Share on other sites More sharing options...
irox Posted December 16, 2009 Author Share Posted December 16, 2009 this is my db: $monday_time1= '08:30'; // db record $lp1 //morning $monday_time2= '12:30'; // db record $lp2 //morning $monday_time3= '20:30'; // db record $lp3 //afternoon $monday_time4= '23:30'; // db record $lp4 //afternoon hio ignace ... yes, i wont achieve closing and opening hours of a store ... I would select a time (eg: 15:00) according to which I will leave all the shops open at that hour Quote Link to comment https://forums.phpfreaks.com/topic/185348-select-beetween-2-times-help-please/#findComment-978500 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.