Best way to handle dynamic amount of form fields in PHP?

后端 未结 2 853
既然无缘
既然无缘 2021-02-04 19:22

I have a system where I need to list an arbitrary amount of employees with a textfield for each day of the week where an \"hours worked\" value can be entered.

So I need

2条回答
  •  一生所求
    2021-02-04 20:02

    will internally convert to an array under $_POST['hoursWorked']. That means you can do something like this:

     
     
     
     
     
     
     
    

    Then, in PHP:

    $dayArray) {
        foreach ($dayArray as $dayOfWeek=>$hoursWorked) {
            // $employeeId will be 12345
            // $dayOfWeek will be 0, 1, 2, 3, 4, 5 ,6
            // $hoursWorked will be the value of the text field
        }
    }
    

提交回复
热议问题