theodore_steiner Posted October 21, 2016 Share Posted October 21, 2016 0down votefavorite I am very, very new to php and require assistance. I have built a multipage form. Most of the inputs on this form can be dynamically created by the user. Here is a working example of this on codepen When the data from the multiDimensional array is passed to the csv sheet I would like to arrange it in the following way: Array ( [0] => Position [1] => Unit [2] => Unit President ), That way, if the user adds two or three inputs dynamically, it will be easier to see each entry. So far I've only been able to filter the array like this: $unitLevelPosition = $_POST["unitLevelPosition"]; $unitLevelPositionValues = ""; foreach( $unitLevelPosition as $unitPositionValue) { $educationHistoryValues .= $unitPositionValue; } The array variable is then added to the rest of the variables being printed to the cvs like this: $csvdata = $firstName . ", " . $lastName . ", " . $educationHistoryValues; Is what I'm after even possible? And if so, can someone help me get started? Quote Link to comment Share on other sites More sharing options...
requinix Posted October 21, 2016 Share Posted October 21, 2016 I see you're still doing the thing I told you to stop doing... Name your original HTML inputs like "input[0][0]" for the position, "input[0][1]" for the unit name, and "input[0][2]" for the president. In your Javascript, make it generate the same sort of thing except keep a counter that starts at 1 and increments every time a new row gets added. The first one added will have input[1][...], the second input[2][...], and so on. If someone removes one the "hole" at that index is not a problem. Then take a look at what's in $_POST. Quote Link to comment 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.