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']);
-
//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>";
-
?>
4 1738
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.
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.
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
In that case think this way,
say staff Alex's id is $id. $id has five appointment. -
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)==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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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
|
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...
| |
by: BHPexpert |
last post by:
Regular Expression help needed
--------------------------------------------------------------------------------
I want to extract all text that is contained inside the brackets after the word...
|
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!
|
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...
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |