Appointment Script
A friend is currently working on a project for a medical facility. They want to be able to allow for people to register with the site, and then schedule time slots to use rehab machines (there are 4 machines). Also, if a machine is reserved for a given time slot, he wants an error message to display saying choose another slot.
He currently has a script he found off of one of those sites (hot scripts, etc) and it works fine, but lacks that customized feel.
Is there a way to display an error message (" Error: Time slot is already filled") if a user tries to submit a time and machine number already submitted by someone else ($time && $machine) ?
Any help is appreciated.
Renegade posted this at 03:24 — 30th May 2004.
He has: 3,022 posts
Joined: Oct 2002
It is quite possible that there is way, are you able to show us the code?
Suzanne posted this at 03:26 — 30th May 2004.
She has: 5,507 posts
Joined: Feb 2000
I don't know how it's determined? It can't be just $time and $machine, there must be some other identifier.
<?php
if ($identifier == 'set flag value') {
$error = 'this is the error message';
} else {
$error = '';
}
?>
and where the error message would go:
<?=$error;?>
mjs416 posted this at 13:50 — 30th May 2004.
They have: 127 posts
Joined: Dec 2003
Well, I have figured out a way to do it with mysql. All that is needed is to simply make the time and machine fields in the db - Unique. This in turns returns a duplicate entry error if you try and schedule an appointment at time X and machine Y; if someone have already reserved the machine Y for time X. Another question has now arisen; is it possible to change the (or modify the) error text returned by mysql with the dyplicat error message ? Currently, the error returned appears as "Duplicate Entry for 'time-machine' key 2. Can I change that to - "There was an error reserving that machine at that time - please click the back button and try a different time slot."
Also, I dont follow your logic suzanne. This "identifier" will need to be compared against every entry in the db, not just a single value.
Suzanne posted this at 16:26 — 30th May 2004.
She has: 5,507 posts
Joined: Feb 2000
My logic is that a) I don't know the script and b) each cell in an appointment book would be unique. So you're db solution is great (and is the identifier...)
date1[time1/slot1, time1/slot2, time1/slot3, time1/slot4]
date1[time2/slot1, time2/slot2, time2/slot3, time2/slot4]
et cetera.
I don't know how this information is recorded, nor how it's determined. Without knowing that, I gave you what I could guess at.
mjs416 posted this at 02:18 — 31st May 2004.
They have: 127 posts
Joined: Dec 2003
Much thanks for your help!!!
I came up with a solution. Based upon $time and $machine being the unique fields of the table, I was having the php display the default error text for a 1062 error (which is duplicate entry for key whatever). This text is stored in the mysql share folder and could be changed very easily on my test server, but not on a customers server. Instead of passing a null argument, I passed a variable called $error, which was defined to have the desired error text.
See? Ya learn something new every day. =)
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.