In dire need of help with an appointment script for php

I am building a website and have written a script that i tested and it works successfully that places information from a form into a MySQL database. This form is for making an appointment with the owner of the website… so this form, before inputting the information into the database needs to first check the database for an appointment already there for the same time…

So my question to you guys for help is : How do I query the MySQL database in php and ask it if there is already an appointment there? and If there is not, it schedules the appointment no problem and inputs the info… however if there is, it should redirect the user to a page “where i can explain that the time slot is filled” can someone please give me an idea of how to accomplish this? I sincerly thank you in advance!!

-GregoryMW

So, you know how to query the database since you have entered data, I am guessing with a SQL insert command. So, basically, you just do it the same way…

You do a standard SQL query requesting the data. Something like…
$query=“SELECT * from appointments WHERE date=‘today’ and time=‘4PM’”;
Execute the query, of course, after you fill in the date and time.
That will give you back a recordset with data or no data.
If data was found, that means that timeslot is taken. If no data found, it is empty.

(Of course, this is simple, you have to count in hours of appointments, one hour, two, three???)

That is just a first starting point for you. When you get further, ask for more help…
(Of course, this was based on your comments, not code or database setup which you did not show us.)

ok thank you very much let me give this a go and ill get back to you with my actual code, thank you so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service