Drainy Posted February 10, 2009 Share Posted February 10, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/144661-handling-post-data-with-unknowns/ Share on other sites More sharing options...
Maq Posted February 10, 2009 Share Posted February 10, 2009 This will give you all the posted values and names. foreach($_POST as $key => $val) { echo "key => " . $key . " val => " . $val; } Quote Link to comment https://forums.phpfreaks.com/topic/144661-handling-post-data-with-unknowns/#findComment-759073 Share on other sites More sharing options...
Drainy Posted February 10, 2009 Author Share Posted February 10, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/144661-handling-post-data-with-unknowns/#findComment-759081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.