Jump to content

using php tables and interacting?


Gazz1982

Recommended Posts

my database:

 

+------------+-------------+------+-----+---------+----------------+
| Field      | Type        | Null | Key | Default | Extra          |
+------------+-------------+------+-----+---------+----------------+
| ID         | int(11)     | NO   | PRI | NULL    | auto_increment |
| EMAIL      | varchar(30) | NO   |     | NULL    |                |
| PASSWORD   | varchar(30) | NO   |     | NULL    |                |
| NAME_FIRST | char(20)    | YES  |     | NULL    |                |
| NAME_LAST  | char(20)    | YES  |     | NULL    |                |
| COMPANY    | char(20)    | YES  |     | NULL    |                |
| ADDRESS1   | varchar(20) | YES  |     | NULL    |                |
| ADDRESS2   | varchar(20) | YES  |     | NULL    |                |
| ADDRESS3   | varchar(20) | YES  |     | NULL    |                |
| COUNTY     | char(20)    | YES  |     | NULL    |                |
| COUNTRY    | char(20)    | YES  |     | NULL    |                |
| POST_CODE  | varchar(  | YES  |     | NULL    |                |
| PHONE      | varchar(30) | YES  |     | NULL    |                |
| DISPOSE    | char(3)     | YES  |     | NULL    |                |
+------------+-------------+------+-----+---------+----------------+
14 rows in set (0.01 sec)

 

this is displayed in a php generated table, I have added a checkbox to each row in the table - how do I make it so that when this check box is ticked it adds 'yes' into the dispose column of that row?

 

Is this possible?

Link to comment
https://forums.phpfreaks.com/topic/109266-using-php-tables-and-interacting/
Share on other sites

Without realoading the page? Yeah, you'll need to use AJAX techniques.

 

If you're happy to have a reload then you'll want to name your checkbox as an array with the value of the checkbox as the ID of the row. You can then implode the array and use IN in your update statement. Something like:

 

$ids = implode(',',$_POST['checkboxes'];
//assuming ID is numerical. Otherwise, you'll need to add quotes around each ID too.
$sql = "UPDATE yourtable SET DISPOSE = 'yes' WHERE ID IN ($ids)";

 

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.