Use a <form> to change database?

Use a <form> to change database?

Postby JPRGO » Mon Feb 25, 2008 10:16 am


I think it's best to explain this with an example:
A customer clicks the month in which he wants to stay,
in the next screen there are 31 checkboxes so he can choose the dates.
How do I make the php script submit the dates he selected to the calender's mysql database?
(so the dates in the calender get automatically updated?)

Posts: 2
Joined: Sun Feb 24, 2008 9:21 pm
Location: Middelharnis, the Netherlands

Re: Use a <form> to change database?

Postby chris » Fri Feb 29, 2008 3:56 pm

Hi there, sorry for the late reply, I have been "away" from the computer all this week.

Right now I have 2 versions working.
Firstly there is the one which is availably from the script page which simply has an "available" or "booked" state.
This works by adding or deleting the date from a table with 2 columns ("id" and "date") so, if it is in the data base it means that it is booked (or unavailable) and if it isn't in the database, it means that it is available.
Clearly this is a rather simple use of the calendar, bear in mind that it was meant more as an example of ajax updating.

Then there is the new version which I am working on and have published in another thread viewtopic.php?f=9&t=8 This is slightly more advanced in that it now has a third column in the database table which is called "state" (I think, I haven't got the code to hand). That column currently has the 3 possible states "all" (ie all day booked) "am" (morning booked) and "pm" (afternoon booked). Obviously this column could accept whatever definitions you would like to add to it and in a more efficient database use, this column would ideally only accept numeric values which would in turn relate to their values and there reduce database load (eg 1=all day, 2=morning, 3=afternoon etc.) But for ease of understanding I have left this demo using the codes.

To be able to collect client reservations, you would also need a further column called, for example, "id_client", this would record the id of the client (you would have to previously save the client details in another table and get the id from there) and therefore allow you to link the booking to the client.

I hope this is more or less what you where after and I hope you can follow it, I am trying to write it quickly so as you don't think that I have missed your post. Don't hesitate to ask more questions if this is not what you are after ;)

Hopefully I will have time this weekend to finish off the new version and make it public with some new comments about the new columns.

User avatar
Site Admin
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests