Jump to content

Processing multiple checkbox selections PHP


sngumo

Recommended Posts

Hi,

 

I have this problem I have a PHP page which generates a table with multiple rows, each with a given query result. Example:

 

Id.    Name    Email                    Age  Level

1      Martin  [email protected]    27    user

2      Tom      [email protected]      25    manager

3      Alex      [email protected]    26    user

 

Now I would like to put a checkbox next to each of the rows so that I can select multiple rows and process them at once if maybe I wanted to delete them or perform any other processing on the selected rows.

 

How can I achieve this?

 

Thanks in advance

on each row have a checkbox with a name ending with "[]" to create an array. Give each c/box a value of that rows id

<input type='checkbox' name='cbox[]' value='{$row['id']}' />

 

To process, only checked values are posted, so

 

$idlist = join (',', $_POST['cbox']);

$sql = "SELECT name, email FROM table WHERE id IN ($idlist);

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.