PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am creating a booking system and have done the form and created all the fields in a SQL database, im only a beginner @ PHP so need some help but basically once the forms been filled out i want it to submit the details to the database which i can get it to do. the thing im getting stuck on is either using a function or array or if statement so where by if that same form gets filled out again it checks to see if the time thats been entered is the same as one already there or within 1hr of that time if so then to return an error just underneath that box saying sorry time already taken please choose another.
Also so that the form will only submit so many entrys per day and to then also be able to click on a button so it input entrys for a specfic day into a PDF template.
it depends on how your fields are set up on your table:
if they are set up as datetime or just time fields, you can query off of the db and determine if the NOW is between the time inserted and one hour after by formatting the data/time with date():
if they are set up as a strings with a time() stamp, you can just determine if the time is between NOW and one hour before by just using the unix time with time().
i have changed one of the fields to a timestamp field now what do i have 2 do to my code and how can i set it up one hour before or after like u explained above.
how will it now if its an hour before or after and to display and error message if that times already been taken
I can't say I've ever used a timestamp field so I'm not sure what format that data will be in.
but regardless you just need to build a query to look for a time block that fits within your time in question and if a row exists, then you can't use it:
$insertime = "9:00 am";
$query = "select * from myTable where time between '".date("G:i",strtotime($inserttime))."' and '".date("G:i",strtotime($inserttime." +1 hour"))."'";
i have tried to query the database but every time i go to load the page up i get it saying saying this : Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in PATHNAME in to lines but the trouble is the name for the table in the database is correct so what else could be causing this