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

Link to comment
Share on other sites

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.

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.