Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:24:32+00:00 2026-06-01T13:24:32+00:00

I am creating a system for my dissertation for a school to use. There’s

  • 0

I am creating a system for my dissertation for a school to use. There’s one aspect I can’t get working though. I want to be able to set attendance for multiple people all at once. There’s an image here that will show you what the form looks like:

multiple attendance form

All values are set to present, so only a couple can be chaged to absent if need be. Once the button is pressed at the bottom of the form, I would like it to navigate to a confirmation page. I have used a MySQl query to get a list of staff members whose attendance has not already been set and used an include tag to place this in an HTML form. The code I have to produce the list is as follows:

<?php
// Get a list of all items and display them in ID order
$dynamicList = "";
$sql = mysql_query("SELECT StaffID, StaffName FROM StaffDetails WHERE StaffID NOT IN (SELECT StaffID FROM StaffAttendance WHERE AttendanceDate = curdate()) ORDER BY StaffID ASC");

// Show list
$productCount = mysql_num_rows($sql);
$setTodaysAttendanceList = "";
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)) {
    $StaffID = $row["StaffID"];
    $StaffName = $row["StaffName"];
    $setTodaysAttendanceList .= '<tr style="font-size:15px;">
  <td><a href="../staff_member_details.php?id=' . $StaffID . '">' . $StaffID . '</a></td>
  <td><a href="../staff_member_details.php?id=' . $StaffID . '">' . $StaffName . '</a></td>
  <td><label>
<select name="attendance_status" id="attendance_status">
<option value="Present">Present</option>
<option value="Absent">Absent</option>
</select>
</label></td>
  <td><label>
<textarea cols="21" rows="5" name="notes" id="notes" placeholder="Enter notes here..."></textarea>
</label></td>
</tr>';
}
} else {
$setTodaysAttendanceList = "There are no records listed at this time";
}
mysql_close();
?>

Then within the HTML I have this:

<form action="set_multiple_staff_attendance_confirm.php" enctype="multipart/form-data" name="StaffAttendanceForm" id="StaffAttendanceForm" method="post">
    <?php echo $setTodaysAttendanceList; ?>
    <tr style="font-size:15px;">
      <td></td>
      <td></td>
      <td></td>
      <td><label>
      <input type="submit" name="addNewRow" id="addNewRow" value="Add Staff Attendance Records" />
      </label></form></td>
    </tr>

When it redirects to the next page, I have an insert query that looks like this:

<?php
// Add row to database
if (isset($_POST['staff_id'])) {
$staff_id = mysql_real_escape_string($_POST['staff_id']);
$attendance_status = mysql_real_escape_string($_POST['attendance_status']);
$notes = mysql_real_escape_string($_POST['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();
}
?>

I know this is a long and convoluted way of asking, but I’m just showing that I’ve had a go and am completely stuck!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:24:33+00:00Added an answer on June 1, 2026 at 1:24 pm

    It looks to me like you are checking for $_POST["staffid"], but your select menus have name="attendance_status" set.

    You should rather set the names of your select menus like this:

    name="attendance_status[]"
    

    Then in your php script you read an array – not a single value – when you do $_POST["attendance_staff"].

    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 staffid[] and whose value is the staffid.

    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.

    EDIT: For example, you could use this code to name your form elements (untested):

    <select name="$staffID_attendance_status" id="$staffID_attendance_status">
        <option value="Present">Present</option>
        <option value="Absent">Absent</option>
    </select>
    <textarea cols="21" rows="5" name="$staffID_notes" id="$staffID_notes" placeholder="Enter notes here..."></textarea>
    <input type='hidden' name='staffID[]' value='$staffID'>
    

    Note that this will also give all your form elements unique ids which is necessary if you want your HTML to validate.

    Then in your script you could do this:

    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();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a system where is use e-mail address as unique identifier. There
I am creating a Point System, and once people get enough points, they can
i am creating a system. What i want to know is if a msg
I'm interested in creating a system where the user can define the steps in
I am creating a system where users can setup mailings to go out at
I am creating a system tray program with a shortcut/context menu, but I can't
I am creating a system where a user can select any combination of four
We are creating a system in Ruby on Rails and we want to be
i am Creating messaging system in asp.net. how can i call client on database
I'm creating a system where users can refer other users and in turn receive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.