Jump to content

Recommended Posts

Hi,

 

Ive posted a few times on here for help with a booking / calender system ive been making and so far thanks to some help here and a few hints on a javascript forum ive learnt loads and ive come leaps and bounds.

Sadly I have one more obsticle which I just cant get over because I really cant think (or know of) a way to do this;

My PHP script creates a calender generated from the current date so it starts on the right month.

On this calender you can select table cells which you want to book, with Javascript ive got it changing colour on click and after a suggestion here (and a fair bit of trial and error) I have it using javascript DOM to create and remove hidden form fields for each table cell.

So javascript aside what I have essentially is a form field for selected cells with an ID of $month$daynum, eg for the 5th of february it would have an id february5.

The value assigned to these (not for any reason, I just made a choice to give them all the same value) is 1.

On submit it passes all these selected dates through to a script which at the moment just displays the contents of the post data just so I could test that it worked.

What I need now is to save the contents of each entry of post into its own variable, but not lose the importance of its existing name (the month and date).

Any suggestions of how I could do this?

My only thought at the moment is to use a while and incrementally go through an array made from the post data but if I dont know how many dates will be submitted then I dont know a way around dynamically naming and generating variables.

Im more than happy to research and create the code myself but im a bit stuck where to go, or if ive overcomplicated this.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/144661-handling-post-data-with-unknowns/
Share on other sites

How does this sound, I am trying to code this as I speak but I dont want to create something that is too heavy.

Within the foreach I use explode and an if statement to identify what month the val consists of. I then use 12 arrays, one for each month, and save the days inside of them.

This will produce however many arrays with values in dependant on whatever has been booked and then I can set about saving that to the database.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.