As for the start and end time, your column should be a timestamp type, which takes the form of.
YYYY-MM-DD H:M:S
or,
PHP Code:
date('Y-m-d H:i:s');
PHP Code:
$start = (isset($_POST['start') && preg_match('~[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}\s[a|p]m)?~',$_POST['start'])) ? $_POST['start'] : die('Starting Time is out of sequence');
$end = (isset($_POST['end']) && preg_match('~[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}\s[a|p]m)?~',$_POST['end'])) ? $_POST['end'] : die('Ending Time is out of sequence');
$startTime = date('Y-m-d H:i:s',strtotime($start));
$endTime = date('Y-m-d H:i:s',strtotime($end));
$sql = "INSERT INTO times(StartTime,EndTime) VALUES ('$startTime','$endTime')";
Why not use a TIMESTAMP field, and insert a time() value? That way you have several mysql function available to manipulate the time data (such as DATEDIFF, TIMESTAMPDIFF, DATE_FORMAT, etc.)
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks
ID int(11) No None auto increment
Title varchar(65) latin1_swedish_ci No None
Detail varchar(255) latin1_swedish_ci No None
eventDate varchar(10) latin1_swedish_ci No None
dateAdded date No None
starttime varchar(265) latin1_swedish_ci No None
endtime varchar(265) latin1_swedish_ci No None
status int(1) No None
tutorid int(8) No None
This is the code, it works, but when i am trying to add the tutorid, it does not
PHP Code:
<?php
mysql_connect("localhost", "checkbox", "checkbox") or die (mysql_error());
echo "Connected to Mysql<br/><hr/>";
mysql_select_db("checkbox") or die (mysql_error());
I cant get the mysql statement to work I WANT TO SHOW EVERY CALENDER FOR EVERY TUTOR.
SO WHEN PEOPLE CHOOSE A TUTOR BRING HIS OWN CALENDAR HOURS... THEN IT WILL POPULATE THE TUTOR WITH HIS RESPECTIVE HOURS AVAILABLE FOR THE DAY... THEN IF THE CUSTOMER WANTS TO MAKE AN APPOINTMENT IT JUST CLICK A CHECK BOX AND MAKE THE CHANGES IN THE DB. Then if someone else require the same tutor when they click the same day it will shows the schedule with the hours available (unchecked box) and unavailable (checkedbox)
Notice: Undefined variable: tutorid in C:\wamp\www\calendar3\calendar.php on line 174
Tutors Schedule for Today
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\calendar3\calendar.php on line 184
and this is the mysql statement
$sqlEvent = "SELECT starttime, endtime,tutorname FROM eventcalender where eventDate='".$month."/".$day."/".$year."' AND tutorname =$tutorid";