Jump to content

[SOLVED] insert into db only is isset


rvdb86

Recommended Posts

Hi,

 

I have a list of check box options that is generated from the database.

I need to insert values into a table only if they have been selected by the user.

 

each name of the check boxes starts with area and then the id. eg: area1, area2 etc..

 

I am pretty sure i need a for loop I'm just not to sure about the format.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/176742-solved-insert-into-db-only-is-isset/
Share on other sites

thanks for the reply but maybe i did not explain the problem properly.

 

Because the list of check boxes is generated from a database I do not know how many options the user will have.

therefore I cannot use the following code:

if (isset(area1)){
code
}

if (isset(area2)){
code
}

 

I think I need to create an array of all the $_POST variables that start with area and then insert their values.

 

Again this is a guess and I may be wrong. However I hope the problem is clearer now.

what do your checkboxes look like? they should be of the format

<input type="checkbox" name="boxes[]" value="something" />clicky
<input type="checkbox" name="boxes[]" value="somethingelse" />clicky1
<input type="checkbox" name="boxes[]" value="athirdvalue" />clicky2

 

when you submit a checkbox, on the values that were selected will be in the $_POST['boxes'] array.

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.