Created
February 5, 2011 01:04
-
-
Save casspangell/812091 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Calendar</title> | |
<!-- link calendar files --> | |
<script language="JavaScript" src="calendar_us.js"></script> | |
<link rel="stylesheet" href="calendar.css"> | |
</head> | |
<body> | |
<?php | |
$username="cpangell_irt"; | |
$password="irtsoftware"; | |
$database="cpangell_calendar"; | |
if(isset($_POST['calendar'])){ | |
$schedule_of_day=$_POST['calendar']; | |
mysql_connect("localhost",$username,$password) or die(mysql_error()); | |
mysql_select_db($database); | |
//query the db | |
$query="SELECT schedule_of_day, 8time, 9time, 10time, 11time, 12time, 13time, 14time, 15time, 16time, 17time, 18time, 19time FROM Calendar WHERE schedule_of_day = '" . $schedule_of_day . "'"; | |
$result = mysql_query($query); | |
$array = mysql_fetch_array($result); | |
$availarr = array(); | |
$timearr = array(0, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7); | |
//Date already has a schedule | |
if($array == NULL){ | |
mysql_query("INSERT INTO Calendar (schedule_of_day, 8time, 9time, 10time, 11time, 12time, 13time, 14time, 15time, 16time, 17time, 18time, 19time) VALUES ('" . $schedule_of_day . "', '', '', '', '', '', '', '', '', '', '', '', '')"); | |
} | |
echo "Select a time by clicking on the calendar to see available times <br /><br />"; | |
echo "<form id=\"form\" name=\"form\" method=\"post\" action=\"requesttime.php\"> | |
<label>Please select an available time: | |
<select name=\"list\" id=\"list\">"; | |
for($i=1; $i<13; ++$i){ | |
if($array[$i] == NULL){ | |
if(($timearr[$i] > 0) && ($timearr[$i] < 8)){ | |
echo "<option value=\"" . $timearr[$i] . "\">"; | |
echo $timearr[$i] . ":00pm" . "<br />"; | |
$availarr[]= $timearr[$i] . ":00pm" . "<br />"; | |
echo "</option>"; | |
} | |
else{ | |
echo "<option value=\"" . $timearr[$i] . "\">"; | |
echo $timearr[$i] . ":00am" . "<br />"; | |
$availarr[]= $timearr[$i] . ":00am" . "<br />"; | |
echo "</option>"; | |
} | |
} | |
} | |
echo"<input name=\"day\" type=\"hidden\" id=\"day\" value=\"" . $schedule_of_day . "\" />"; | |
echo "</select></label>"; | |
echo "<label> | |
<input type=\"submit\" name=\"submitTime\" id=\"submitTime\" value=\"Submit\" /> | |
</label> | |
</form>"; | |
?> | |
<form name="testform" method="post" action="calendar_v2.php"> | |
<!-- calendar attaches to existing form element --> | |
<input type="text" name="calendar"/> | |
<script language="JavaScript"> | |
new tcal ({ | |
// form name | |
'formname': 'testform', | |
// input name | |
'controlname': 'calendar' | |
}); | |
</script> | |
<br /> | |
<label> | |
<input type="submit" name="submit" id="submitBtn" value="See Available Times" /> | |
</label> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment