Jump to content

Getting table row data based on ticked checkbox


mrherman

Recommended Posts

I'm stuck with a checkbox problem. I have a db that contains names and unique id numbers.  There are thousands of rows.

 

Using a query, I am pulling selected students and showing them to a user in an ultra simple HTML table on a form.

 

Each row begins with a checkbox. The method is POST.

 

So far, so good. My table kinda looks like this (very simplified):

 

+-----------+----------+----------+
|   SELECT  |    NAME  |    ID    |
+-----------+----------+----------+
|   []      |    John  |    2233  |
+-----------+----------+----------+
|   []      |    Susie |    5577  |
+-----------+----------+----------+

[-SUBMIT-]

 

My problem is that I cannot seem to make the selected checkboxes associate with each student's name and unique ID. Once the user has selected rows and clicked SUBMIT, the $_POST array remains empty.

 

How can I get the values of the NAME and ID (etc.) when a checkbox is ticked??

 

Thanks for any help

You should just need the ID, since the ID should be associated with all the details for the student. You should create the checkboxes as arrays and se the value as the ID of the record

<input type="checkbox" name="students[]" value="<?php echo $row['id']; ?>" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.