Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks to me like you are checking for <code>$_POST["staffid"]</code>, but your select menus have <code>name="attendance_status"</code> set. </p> <p>You should rather set the names of your select menus like this:</p> <pre><code>name="attendance_status[]" </code></pre> <p>Then in your php script you read an array - not a single value - when you do <code>$_POST["attendance_staff"]</code>.</p> <p>EDIT: This will only work if you also have an array available with all the corresponding staffids. You can get this by using a hidden input for every row whose name is <code>staffid[]</code> and whose value is the staffid.</p> <p>However, a more reliable way would probably be to use the staffid inside the name of every saveable form element, as David-SkyMesh pointed out in a comment to your post.</p> <p>EDIT: For example, you could use this code to name your form elements (untested):</p> <pre><code>&lt;select name="$staffID_attendance_status" id="$staffID_attendance_status"&gt; &lt;option value="Present"&gt;Present&lt;/option&gt; &lt;option value="Absent"&gt;Absent&lt;/option&gt; &lt;/select&gt; &lt;textarea cols="21" rows="5" name="$staffID_notes" id="$staffID_notes" placeholder="Enter notes here..."&gt;&lt;/textarea&gt; &lt;input type='hidden' name='staffID[]' value='$staffID'&gt; </code></pre> <p>Note that this will also give all your form elements unique ids which is necessary if you want your HTML to validate.</p> <p>Then in your script you could do this:</p> <pre><code>foreach ($_POST["staffID"] as $staffID) { $staff_id = mysql_real_escape_string($staffID); $attendance_status = mysql_real_escape_string($_POST[$staff_id . "_attendance_status"]); $notes = mysql_real_escape_string($_POST[$staff_id . "_notes"]); $sql .= mysql_query("INSERT INTO StaffAttendance (StaffID, AttendanceDate, AttendanceStatus, Notes) VALUES ('$staff_id', now(), '$attendance_status', '$notes')") or die (mysql_error()); $editid = mysql_insert_id(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload