php - Insert Timeslot In mysql Table -
i'm developing system using php , mysql. 1 of form prompt user fill-up 2 textbox namely starttime
, endtime
. user must fill-up both text box , when submitted, insert them table named slot
, output them along previous data.
5:30 6:00 6:30 7:00 7:30 8:00
how can it? guide me along answer. here's code:
$i=0; $sid=1; $appointmentsdate=$_request['stime']; $appointmentedate=$_request['etime']; for($appointmentsdate;$appointmentsdate<$appointmentedate;$appointmentsdate++) { $arraystarttime[$i]="{$appointmentsdate}:00"; $i++; $arraystarttime[$i]="{$appointmentsdate}:30"; $i++; } echo "<pre>"; print_r($arraystarttime); die; ($k=0; $k<sizeof($arraystarttime); $k++) { sjb_db::query('insert `schedule_slot` (`schedule_id`,`starttime`,`endtime`) values (?s,?s,?s)',$sid,$arraystarttime[$k],$arraystarttime[$k+1]); }
thank in advance.
#your inputs $start = "11:00"; $time_end = "13:30"; #converting them timestamps $time_start = strtotime($start); $time_end = strtotime($time_end); #looping while($time_start <= $time_end){ $somearr[] = date("h:i",$time_start)."\n"; $time_start = strtotime('+30 minutes',$time_start); }
integrating current code, should (untested):
$i=0; $sid=1; $appointmentstimestart = strtotime($_request['stime']); $appointmentstimeend = strtotime($_request['stime']); for($appointmentstimestart; $appointmentstimestart<$appointmentstimeend; $appointmentsdate1++) { $arraystarttime[$i] = date("h:i", $appointmentstimestart); $appointmentstimestart = strtotime('+30 minutes',$appointmentstimestart); $i++; } print_r($arraystarttime);
Comments
Post a Comment