Jump to content

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']; ?>" />

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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