Help needed in appointment booking:(
Posted: Thu Sep 16, 2010 9:27 pm
Hi to all,
i am preparing an appointment booking web site for my uni project. However i am stuck on the last booking.php file. It enters the appointment start time and endtime however it shows Start Time: 11:00:00
Finish Time: 11:30:00
Duration: 0:30:00
Have been taken please select other times
and it inserts the information to the database however it does not overwrite it. Very interesting:))) Please take a look at the code and tell me what should i do cos i am not expert in php> Thanks
<?php
session_start();
include ("db.php");
$sectionname="Welcome To Berna's Unisex Hair Salon";
$pagename="Choose Staff";
echo "<html>";
echo "<head>";
echo "<title>".$sectionname.">>>".$pagename."</title>";
echo "<link rel=stylesheet type=text/css href=pageform.css>";
echo "</head>";
echo "<body>";
echo "<center><i><h1 style=calibre;color:black>Berna's Unisex Hair Salon Page</h1><i/>";
echo "<center><b><i><p style=calibre;color:black>Since 1994</p></i></b>";
echo date ('l d F Y H:i:s');
echo "<hr><img src=header.jpg><hr>";
echo "</center>";
echo "<br>";
echo "<br>";
$sesstaff = $_SESSION['staff'];//staffid
$sesclient = $_SESSION['userid'];//client id
$_SESSION['date'];//date
$sestime = $_SESSION['time'];//time
$TotalNoservice = count($_SESSION['sel1']);/counting number selected duration id
//serviceId serviceName serviceDuration
$alltime = 0;
for($i=0; $i<$TotalNoservice; $i++)
{
$ServiceName = $_SESSION['sel1'][$i];
$query="select duration from services where service_id = $ServiceName";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$alltime = $alltime + $row['duration'];
}
}
$th = substr($sestime, 0, 2);
$tm = substr($sestime, 3, 2);
$ts = substr($sestime, 6, 2);
$th = $th + floor($alltime/3600);
$th2 = floor($alltime/3600);
$alltime = $alltime - floor($alltime/3600)*3600;
$tm = $tm + floor($alltime/60);
$tm2 = floor($alltime/60);
$alltime = $alltime - floor($alltime/60)*60;
$ts = $ts + $alltime;
$ts2 = $alltime;
if ($ts < 10) $ts = "0".$ts;
if ($ts2 < 10) $ts2 = "0".$ts2;
$result = mysql_query("SELECT * FROM booking WHERE staff_id='$sesstaff'");
$found = 0;
while($row = mysql_fetch_array($result))
{
$csh = substr($row['booking_start'], 0, 2);
$cfh = substr($row['booking_end'], 0, 2);
if(substr($sestime, 0, 2) >= $csh && substr($sestime, 0, 2) <= $cfh)
{
$found = 1;
}
if(substr($th, 0, 2) >= $csh && substr($sestime, 0, 2) <= $cfh)
{
$found = 1;
}
}
echo "Start Time: ".$sestime."<br>";
echo "Finish Time: ".$th.":".$tm.":".$ts."<br>";
echo "Duration: ".$th2.":".$tm2.":".$ts2."<br>";
if($found == 1){
echo "Have been taken please select other times";
}
elseif($found == 0)
{
echo "Your times have been booked thanks for booking with COMPANY NAME";
$finishtime = $th.":".$tm.":".$ts;
mysql_query("INSERT INTO booking (client_id, staff_id, booking_start, booking_end)VALUES ('$sesclient', '$sesstaff', '$sestime', '$finishtime')");
}
echo "</body>";
echo "</html>";
?>
i am preparing an appointment booking web site for my uni project. However i am stuck on the last booking.php file. It enters the appointment start time and endtime however it shows Start Time: 11:00:00
Finish Time: 11:30:00
Duration: 0:30:00
Have been taken please select other times
and it inserts the information to the database however it does not overwrite it. Very interesting:))) Please take a look at the code and tell me what should i do cos i am not expert in php> Thanks
<?php
session_start();
include ("db.php");
$sectionname="Welcome To Berna's Unisex Hair Salon";
$pagename="Choose Staff";
echo "<html>";
echo "<head>";
echo "<title>".$sectionname.">>>".$pagename."</title>";
echo "<link rel=stylesheet type=text/css href=pageform.css>";
echo "</head>";
echo "<body>";
echo "<center><i><h1 style=calibre;color:black>Berna's Unisex Hair Salon Page</h1><i/>";
echo "<center><b><i><p style=calibre;color:black>Since 1994</p></i></b>";
echo date ('l d F Y H:i:s');
echo "<hr><img src=header.jpg><hr>";
echo "</center>";
echo "<br>";
echo "<br>";
$sesstaff = $_SESSION['staff'];//staffid
$sesclient = $_SESSION['userid'];//client id
$_SESSION['date'];//date
$sestime = $_SESSION['time'];//time
$TotalNoservice = count($_SESSION['sel1']);/counting number selected duration id
//serviceId serviceName serviceDuration
$alltime = 0;
for($i=0; $i<$TotalNoservice; $i++)
{
$ServiceName = $_SESSION['sel1'][$i];
$query="select duration from services where service_id = $ServiceName";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$alltime = $alltime + $row['duration'];
}
}
$th = substr($sestime, 0, 2);
$tm = substr($sestime, 3, 2);
$ts = substr($sestime, 6, 2);
$th = $th + floor($alltime/3600);
$th2 = floor($alltime/3600);
$alltime = $alltime - floor($alltime/3600)*3600;
$tm = $tm + floor($alltime/60);
$tm2 = floor($alltime/60);
$alltime = $alltime - floor($alltime/60)*60;
$ts = $ts + $alltime;
$ts2 = $alltime;
if ($ts < 10) $ts = "0".$ts;
if ($ts2 < 10) $ts2 = "0".$ts2;
$result = mysql_query("SELECT * FROM booking WHERE staff_id='$sesstaff'");
$found = 0;
while($row = mysql_fetch_array($result))
{
$csh = substr($row['booking_start'], 0, 2);
$cfh = substr($row['booking_end'], 0, 2);
if(substr($sestime, 0, 2) >= $csh && substr($sestime, 0, 2) <= $cfh)
{
$found = 1;
}
if(substr($th, 0, 2) >= $csh && substr($sestime, 0, 2) <= $cfh)
{
$found = 1;
}
}
echo "Start Time: ".$sestime."<br>";
echo "Finish Time: ".$th.":".$tm.":".$ts."<br>";
echo "Duration: ".$th2.":".$tm2.":".$ts2."<br>";
if($found == 1){
echo "Have been taken please select other times";
}
elseif($found == 0)
{
echo "Your times have been booked thanks for booking with COMPANY NAME";
$finishtime = $th.":".$tm.":".$ts;
mysql_query("INSERT INTO booking (client_id, staff_id, booking_start, booking_end)VALUES ('$sesclient', '$sesstaff', '$sestime', '$finishtime')");
}
echo "</body>";
echo "</html>";
?>