Hi
I am php newbie and I don't know if I am approaching this properly.
I need to creat a scheduler that list the appointment time on the left
and client for a specific appointment time on the left.
NOTE: The appointments are stored in a Mysql database
This is what I am trying to acomplish:
Time | client Name
-------------------------------------------
09:00 AM |
10:00 AM | John Smith
11:00 AM |
to
09:00 PM | Mike Smith
The problem I am having is getting the appointments on the
right to match up with the time on the left.
This is what I am getting with the code below:
Time | client Name
------------------------------------------------
09:00 AM | John Smith
10:00 AM | Mike Smith
11:00 AM |
to
09:00 PM |
<?
/**--------------------------time interval--------------------**/
//array with time interval listing found on the left side of the page
$time_60min_array = array(
'06:00 AM', '07:00 AM', '08:00 AM', '09:00 AM', '10:00 AM', '11:00 AM',
'12:00 PM', '01:00 PM', '02:00 PM', '03:00 PM', '04:00 PM', '05:00 PM',
'06:00 PM', '07:00 PM', '08:00 PM', '09:00 PM');
/**-------------select appointment from database-----------------**/
// select by date to match to time interval listing
$query = "SELECT distinct(event_id), event_date, event_time, event_am_pm,
first_name, last_name,
FROM cal_appointment
WHERE event_date = '$event_date'
ORDER BY event_date, event_am_pm, event_time";
$result = mysqli_query($mysqli, $query) or die('Error, query failed');
/**-------------------------------title--------------------------**/
echo "<div id=\"Layer4\" style=\"position:absolute; margin: 4px; width:100%; height:20px; z-index:4; left: 4px; top: 430px;\">\n";
echo "<table width=\"98.5%\" margin=\"\" left =\"4\" align=\"center\">
<tr>
<td width=\"30%\" height=\"12\" align=\"center\" bgcolor=\"#eeeee0\"><span class=\"style20\"><strong>Time</strong></span></td>
<td width=\"68%\" height=\"12\" align=\"center\" bgcolor=\"#eeeee0\"><span class=\"style20\"><strong>Patient</strong></span></td>
</tr>\n";
echo "</table>\n";
echo "</div>\n";
//search area display area layer and table
echo "<table width=\"99%\" border=\"0\">
<tr align=\"center\" bgcolor=\"#FFFFFF\" height=\"\">
<td width=\"100%\" >
<div id=\"Layer2\" style=\"position:absolute; width:100%; height:500px; z-index:2; left: 4px; top: 465px;\">
<div id=\"scroll-box2\" style=\"overflow: auto; float: left; width: 100%; height: 480px; margin: 5px; \">\n";
//table begins
echo "<table width=\"100%\" height=\"332\" left =\"4\" align = \"\" border=\"0\" font face =\"arial\">\n";
/**--------------------------display------------------------**/
$result = mysqli_query($mysqli, $query) or die('Error, query failed');
for($i=0; $i < count($time_60min_array ); $i++)
{
$row = mysqli_fetch_array($result);
list($event_id, $event_date, $event_time, $event_am_pm,$first, $last) = $row;
//format time
$appoint_time = $hour.":".$minutes." ".$am_pm;
//match appointment time on right to time listing on left
if(in_array($appoint_time, $time_60min_array))
{
$s_event_id = $event_id;
$client_name = $last.", ".$first;
}
//display list
echo"<tr height=\"10\">
<td width=30% height=\"10\" bgcolor=\"$bgcolor\" align=\"center\">$time_interval[$i]</td>
<td width=\"70%\" height=\"10\" bgcolor=\"$bgcolor\"><span class=\"style20\">$client_name</td>\n";
echo"</tr>\n";
}
?>