Jump to content

theodore_steiner

New Members
  • Posts

    4
  • Joined

  • Last visited

theodore_steiner's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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?
  2. Thank you so very much for the help! I promise I won't do anything weird! One last question, the fputcsv($fp, $line_of_csv_data) line of code, wouldn't appear in the code below but after yes? $csvdata = $firstName . ", " . $lastName . ", " . $homeAddress . ", " . $homeAddressTwo . ", " . $city . ", " . $province . ", " . $postalCode . ", " . $homePhone . ", " . $personalEmail . ", " . $confirmEmail . ", " . $oectaNumber . ", " . $memberStatus . ", " . $teacherTraining . ", " . $teachingYears . "," . $employmentHistoryValues; $fp = fopen("formdata.csv", "a"); if($fp) { fwrite($fp, $csvdata . "\n"); fclose($fp); }
  3. Combining the values would work perfectly. So would multiple rows. But what I was afraid of was lets say user1 puts in 2 inputs dynamically, and then user2 puts in 3inputs dynamically, won't the csv get confused as to which row belongs to which set of user input data? I'm sorry to press, but how would I go about doing one or both of those methods?
  4. Hi All, I am very new to PHP and I need some help. I've got a multipage form that is made of up straight inputs and inputs that can be created dynamically, on the fly, so people can add in other jobs/degrees/awards. When the user submits, I am trying to load the input results to a .csv file. For the input fields that are not dynamically created this is no problem, but for the ones that are, an I've got it generating an array of values. However, when I pass these values to the csv sheet each new array entry value is taking up the space next to it. Is it possible to have the first set of array values take up the requisite fields and then have the remaining values relative to that particular array section appear below, almost as if you put in a <br> tag? PHP Code: $firstName = $_POST["firstName"]; $lastName = $_POST["lastName"]; $homeAddress = $_POST["homeAddress"]; $homeAddressTwo = $_POST["homeAddressTwo"]; $city = $_POST["city"]; $province = $_POST["province"]; $postalCode = $_POST["postalCode"]; $homePhone = $_POST["homePhone"]; $personalEmail = $_POST["personalEmail"]; $confirmEmail = $_POST["confirmEmail"]; $oectaNumber = $_POST["oectaNumber"]; $memberStatus = $_POST["memberStatus"]; $teacherTraining = $_POST["teacherTraining"]; $teachingYears = $_POST["teachingYears"]; $employmentHistory = $_POST["employmentHistory"]; $employmentHistoryValues = print_r(array_values($employmentHistory)); $csvdata = $firstName . ", " . $lastName . ", " . $homeAddress . ", " . $homeAddressTwo . ", " . $city . ", " . $province . ", " . $postalCode . ", " . $homePhone . ", " . $personalEmail . ", " . $confirmEmail . ", " . $oectaNumber . ", " . $memberStatus . ", " . $teacherTraining . ", " . $teachingYears . "," . $employmentHistoryValues; $fp = fopen("formdata.csv", "a"); if($fp) { fwrite($fp, $csvdata . "\n"); fclose($fp); }
×
×
  • 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.