1

I have a form for saving the attendance of students to the MySQL database.

Students' data is read from the database and create the data entry form.

The form is designed to store the code, name, presence status of each student and a short description in case of absence.

I have designed the data entry form, but seem to need some clues regarding the save action so that clicking on each save button, the appropriate data is stored in the attendance table of the database.A screenshot of the form

user2428118
8,1344 gold badges47 silver badges74 bronze badges
asked Oct 4, 2012 at 12:37
0

1 Answer 1

1

If you don't care about old IE (which has bugs in its support of <button>, I think version 7 fixes this those bugs) then (making sure you are in Standards mode):

<button type="submit" name="row_id" value="insert row id here">Save</button>
$row_id = $_POST['row_id'];

If you do care about old IE:

<input type="submit" name="row_id_row_id_here" value="Save">

and loop over the keys in $_POST looking for ones which match the regex /^row_id_(.*)/.

answered Oct 4, 2012 at 12:46
Sign up to request clarification or add additional context in comments.

2 Comments

or if you want to be really fancy, append a click event to each button and handle the request with ajax. (your js code would look something like $('.save-button-class').on('click', function(e) { alert('saving row with id' + $(this).attr('name')); $.post('...'); });
No, not or. That could be considered as an enhancement once the basic functionality is implemented, but it shouldn't be a replacement.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.