473,503 Members | 9,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed in appointment booking:(

2 New Member
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
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. session_start(); 
  4. include ("db.php");
  5. $sectionname="Welcome To Berna's Unisex Hair Salon";
  6. $pagename="Choose Staff";
  7.  
  8. echo "<html>";
  9. echo "<head>";
  10. echo "<title>".$sectionname.">>>".$pagename."</title>";
  11. echo "<link rel=stylesheet type=text/css href=pageform.css>";
  12. echo "</head>";
  13.  
  14. echo "<body>";
  15. echo "<center><i><h1 style=calibre;color:black>Berna's Unisex Hair Salon Page</h1><i/>";
  16. echo "<center><b><i><p style=calibre;color:black>Since 1994</p></i></b>";
  17. echo date ('l d F Y H:i:s');
  18. echo "<hr><img src=header.jpg><hr>";
  19. echo "</center>";
  20. echo "<br>";
  21. echo "<br>";
  22.  
  23.  
  24. $sesstaff = $_SESSION['staff'];//staffid
  25. $sesclient = $_SESSION['userid'];//client id
  26. $_SESSION['date'];//date
  27. $sestime = $_SESSION['time'];//time
  28.  
  29.  
  30. $TotalNoservice = count($_SESSION['sel1']);
  31. //serviceId  serviceName  serviceDuration
  32.  
  33. $alltime = 0;
  34. for($i=0; $i<$TotalNoservice; $i++)
  35. {
  36.     $ServiceName = $_SESSION['sel1'][$i];
  37.     $query="select duration from services where service_id = $ServiceName";
  38.     $result = mysql_query($query);
  39.  
  40.     while($row = mysql_fetch_array($result))
  41.     {
  42.         $alltime = $alltime + $row['duration'];
  43.     }
  44.  
  45.  
  46. }
  47.  
  48.  
  49. $th = substr($sestime, 0, 2);
  50. $tm = substr($sestime, 3, 2);
  51. $ts = substr($sestime, 6, 2);
  52.  
  53. $th = $th + floor($alltime/3600);
  54. $th2 = floor($alltime/3600);
  55. $alltime = $alltime - floor($alltime/3600)*3600;
  56.  
  57. $tm = $tm + floor($alltime/60);
  58. $tm2 = floor($alltime/60);
  59. $alltime = $alltime - floor($alltime/60)*60;
  60.  
  61. $ts = $ts + $alltime;
  62. $ts2 = $alltime;
  63.  
  64. if ($ts < 10) $ts = "0".$ts;
  65. if ($ts2 < 10) $ts2 = "0".$ts2;
  66.  
  67.  
  68.  
  69.  
  70. $result = mysql_query("SELECT * FROM booking WHERE staff_id='$sesstaff'");
  71.  
  72. $found = 0;
  73. while($row = mysql_fetch_array($result))
  74.  {
  75.     $csh = substr($row['booking_start'], 0, 2);
  76.     $cfh = substr($row['booking_end'], 0, 2);
  77.     if(substr($sestime, 0, 2) >= $csh && substr($sestime, 0, 2) <= $cfh)
  78.     {
  79.         $found = 1;
  80.     }
  81.     if(substr($th, 0, 2) >= $csh && substr($sestime, 0, 2) <= $cfh)
  82.     {
  83.         $found = 1;
  84.     }
  85.  
  86.  }
  87.  
  88.  
  89.  
  90. echo "Start Time: ".$sestime."<br>";
  91. echo "Finish Time: ".$th.":".$tm.":".$ts."<br>";
  92. echo "Duration: ".$th2.":".$tm2.":".$ts2."<br>";
  93.  
  94. if($found == 1){
  95.     echo "Have been taken please select other times";
  96. }
  97. elseif($found == 0)
  98. {
  99.     echo "Your times have been booked thanks for booking with COMPANY NAME";
  100.     $finishtime = $th.":".$tm.":".$ts;
  101.     mysql_query("INSERT INTO booking (client_id, staff_id, booking_start, booking_end)VALUES ('$sesclient', '$sesstaff', '$sestime', '$finishtime')");
  102. }
  103.  
  104.  
  105.  
  106. echo "</body>";
  107. echo "</html>";
  108. ?>
Sep 17 '10 #1
4 1738
johny10151981
1,059 Top Contributor
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.
Sep 17 '10 #2
Markus
6,050 Recognized Expert Expert
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.
Sep 17 '10 #3
mehmet23
2 New Member
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
Sep 17 '10 #4
johny10151981
1,059 Top Contributor
In that case think this way,

say staff Alex's id is $id. $id has five appointment.
Expand|Select|Wrap|Line Numbers
  1. appointment_id           time               duration
  2. 01                       9:30               30
  3. 04                       10:15              30
  4. 08                       11:00              30
  5. 10                       12:30              30
  6. 11                       13:00              30
  7.  
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)==true 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.
Sep 18 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2940
by: Sims | last post by:
Hi, Given a string $txt and an array of strings $txt_array what would be the best/fastest way to search in _insensitive_ case if $txt is in $text_array and, if it is, where is it? Because I...
6
2658
by: Jack Smith | last post by:
Help needed on this question. Any help is appreciated. Thanks in advance. Given a binary string (i.e. a finite sequence of 0's and 1's) we choose any two digit substring 01 and replace it by a...
1
1954
by: worzel | last post by:
Hi All, I am looking for a reg ex that will match email addresses withing <a href=mailto blah > links. Actually, I already crafted my own, but with a slight problem: <a...
2
1465
by: Willie | last post by:
I try to setup SQL Server to work with .NET Framework Anyone here willing to help? Step By Step Help Needed. Thanks
14
2152
by: tbird2340 | last post by:
I want to write an if / then statement and have tried using this: var MyVarMailto; if (Request.Form("LoanRequest") == "Under $250,000") { if (Request.Form("Organization") == "1") { MyVarMailto...
1
1717
by: BHPexpert | last post by:
Regular Expression help needed -------------------------------------------------------------------------------- I want to extract all text that is contained inside the brackets after the word...
1
1253
by: Brian Gallagher | last post by:
I have an aspnet application which I only want part of to be avaliable between the hours of 9am and 5:30pm but I dont know where to start. Help needed!
0
2561
by: Christopher | last post by:
Urgent Help Needed: The EPVH-1.1 Visual Hull Library. Dear All, I am a student doing research in computer vision. The EPVH-1.1 Visual Hull Library will really help a lot in my research. I...
1
2601
by: Joel Fireman | last post by:
Help Needed: Upgrade Fedora 4 / Apache 2 to PHP 5.2.x from 5.0.4 I've been testing Joomla as a content manager for the County offices, and it looks pretty good. Unfortunately, I decided to...
0
7264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.