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
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)";

 

Link to comment
Share on other sites

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.