Checking to see if an appointment time exists - HELP!
Posted: Mon Nov 17, 2008 11:50 am
Here is the code that my form uses. When I run it, it doesn't show all the dates that have appointment times available, only the first date. I verified the apptTime information being stored on my db is formatted exactly the same as the time1 and time2 arrays. I would greatly appreciate any assistance... This has been driving me crazy for some time!
<form action="<? $PHP_SELF ?>" method="post" name="drawDate" onSubmit="return checkform(this);">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td><font color=gray>*required information</font></td>
<td> </td>
</tr>
<tr>
<td>Choose the date you would like to schedule your wellness check</td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<?
$appointmentDate = array("2008-10-15","2008-11-15","2008-11-18","2008-12-16","2008-12-20");
$appointmentDate2 = array();
$today = date("Y-m-d");
for ($i=0; $i<sizeof($appointmentDate); $i++){
$c = array();
$d = array();
$a = array();
$schedule1 = array();
$schedule2 = array();
$apptDateFinal = array();
if(strtotime($appointmentDate[$i]) > strtotime($today)){
array_push($appointmentDate2, $appointmentDate[$i]);
}//end if
}//end for
for($i=0; $i<sizeof($appointmentDate2); $i++){
$c = explode("-", $appointmentDate2[$i]);
$d = mktime(0,0,0,$c[1],$c[2],$c[0]);
$formattedDate = date("m-d-y", $d);
$formattedDate2 = date("l, F d, Y", $d);
$weekday = date("l", $d);
//$formattedDate3 = string($formattedDate);
if ($location == "stateline"){
$query = "SELECT * FROM labAppointmentStateline WHERE apptDate = '$formattedDate' ORDER BY apptTime";}
if ($location == "express"){
$query = "SELECT * FROM labAppointment WHERE apptDate = '$formattedDate' ORDER BY apptTime";}
//echo "<tr><td>Query = SELECT * FROM labAppointment WHERE apptDate = '$formattedDate' ORDER BY apptTime</td></tr>";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
array_push($a, $row[apptTime]);
echo "<tr><td>$row[apptTime] Appointment time on $formattedDate. </td></tr>";
}//end while
if ($weekday == "Saturday") {
for ($g=0; $g<sizeof($time2); $g++){
$foo = in_array($time2[$g], $a, false);
if ($foo == FALSE){
echo "$appointmentDate2[$i]: $time2[$g] is not in the array";
array_push($schedule1, $formattedDate);
}//end if
}//end for
}//end if
if ($weekday != "Saturday") {
for ($h=0; $h<sizeof($time1); $h++){
$bar = in_array($time1[$h], $a, false);
if ($bar == FALSE){
echo "$appointmentDate2[$i]: $time1[$h] is not in the array";
array_push($schedule1, $formattedDate);
}//end if
}//end for
}//end if
}//end for
?>
<select id="apptDate" name="apptDate">
<?
foreach ($schedule1 as $value){
echo "<option value='$value'>$value</option>";
}
?>
<option value="">test</option>
</select> </td>
</tr>
<? echo "<input type=\"hidden\" name=\"location\" value=\"$location\">";?>
<tr>
<td colspan="2"><input type="submit" name="submit2" id="submit2" value="---Continue---"> <input name="Reset" type="reset" id="Reset" value="---Reset---"></td>
</tr>
</table>
</form>
<form action="<? $PHP_SELF ?>" method="post" name="drawDate" onSubmit="return checkform(this);">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td><font color=gray>*required information</font></td>
<td> </td>
</tr>
<tr>
<td>Choose the date you would like to schedule your wellness check</td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<?
$appointmentDate = array("2008-10-15","2008-11-15","2008-11-18","2008-12-16","2008-12-20");
$appointmentDate2 = array();
$today = date("Y-m-d");
for ($i=0; $i<sizeof($appointmentDate); $i++){
$c = array();
$d = array();
$a = array();
$schedule1 = array();
$schedule2 = array();
$apptDateFinal = array();
if(strtotime($appointmentDate[$i]) > strtotime($today)){
array_push($appointmentDate2, $appointmentDate[$i]);
}//end if
}//end for
for($i=0; $i<sizeof($appointmentDate2); $i++){
$c = explode("-", $appointmentDate2[$i]);
$d = mktime(0,0,0,$c[1],$c[2],$c[0]);
$formattedDate = date("m-d-y", $d);
$formattedDate2 = date("l, F d, Y", $d);
$weekday = date("l", $d);
//$formattedDate3 = string($formattedDate);
if ($location == "stateline"){
$query = "SELECT * FROM labAppointmentStateline WHERE apptDate = '$formattedDate' ORDER BY apptTime";}
if ($location == "express"){
$query = "SELECT * FROM labAppointment WHERE apptDate = '$formattedDate' ORDER BY apptTime";}
//echo "<tr><td>Query = SELECT * FROM labAppointment WHERE apptDate = '$formattedDate' ORDER BY apptTime</td></tr>";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){
array_push($a, $row[apptTime]);
echo "<tr><td>$row[apptTime] Appointment time on $formattedDate. </td></tr>";
}//end while
if ($weekday == "Saturday") {
for ($g=0; $g<sizeof($time2); $g++){
$foo = in_array($time2[$g], $a, false);
if ($foo == FALSE){
echo "$appointmentDate2[$i]: $time2[$g] is not in the array";
array_push($schedule1, $formattedDate);
}//end if
}//end for
}//end if
if ($weekday != "Saturday") {
for ($h=0; $h<sizeof($time1); $h++){
$bar = in_array($time1[$h], $a, false);
if ($bar == FALSE){
echo "$appointmentDate2[$i]: $time1[$h] is not in the array";
array_push($schedule1, $formattedDate);
}//end if
}//end for
}//end if
}//end for
?>
<select id="apptDate" name="apptDate">
<?
foreach ($schedule1 as $value){
echo "<option value='$value'>$value</option>";
}
?>
<option value="">test</option>
</select> </td>
</tr>
<? echo "<input type=\"hidden\" name=\"location\" value=\"$location\">";?>
<tr>
<td colspan="2"><input type="submit" name="submit2" id="submit2" value="---Continue---"> <input name="Reset" type="reset" id="Reset" value="---Reset---"></td>
</tr>
</table>
</form>