Help needed in appointment booking:(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mehmet23
    New Member
    • Sep 2010
    • 2

    #1

    Help needed in appointment booking:(

    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
    Code:
    <?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']);
    //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>";
    ?>
    Last edited by Niheel; Sep 17 '10, 03:37 AM.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    very poor technique to implement a web page. Its real hard to find error from page like this.

    Why you expect information to be over written in database?

    11:00:00
    Finish Time: 11:30:00
    Duration: 0:30:00
    Have been taken please select other times
    what is that mean?

    And what you need? Please ask clearly.

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Like johny10151981, I don't really understand your problem, but if I were to guess, I'd say you want to UPDATE data, not INSERT it.

      Comment

      • mehmet23
        New Member
        • Sep 2010
        • 2

        #4
        Thanks

        Dear Sirs,
        Thanks a lot for you replies. I am going crazy with this stuff because i am not php literate. My aim in here is to book an appointment. I have acquired all the selections to this page which has been made in the appointment process. What i really want is to book the selections made into the booking table and if same selections has been made and booked by the by client 1 previously, the system should ask the client2 to make different selection, however if the booking table is empty than it should insert all the selections to the booking table.
        I know it sounds bit confusing but its straight forward, Example
        Client 1: Books an appointment on 15th of september, at 11:00 with staff name alex. Once this is booked another person say client 2 should not make appointment with staff name alex on 15th of september, at 11:00 oclock.
        Cheers. Mem

        Comment

        • johny10151981
          Top Contributor
          • Jan 2010
          • 1059

          #5
          In that case think this way,

          say staff Alex's id is $id. $id has five appointment.
          Code:
          appointment_id           time               duration
          01                       9:30               30
          04                       10:15              30
          08                       11:00              30
          10                       12:30              30
          11                       13:00              30
          forget the date for a while
          look at the table status
          after 01 appointment he has a break from 10:00 to 10:15 which mean 15 minutes
          after 04 appointment he has a break from 10:45 to 11:00 which mean 15 minutes
          after 08 appointment he has a break from 11:30 to 12:30 which mean 60 minutes

          Now if you sort the table in time order not appointment_id order you can easily find out the empty duration to check whether the guest appointment can be fit or not

          As well as you can find out the busy duration to find out whether you fit the appointment or not.

          say a guest want an appointment at 12:15. He cant get an appointment cause his start time (12:00<12:15 and 12:30>12:15)==t rue which mean busy schedule.

          again he cant get a schedule at 10:00 cause, his schedule end time 10:30 which would be in busy schedule too.

          Rest figure out yourself cause its your school project.

          Comment

          Working...