Jump to content

foreach method


Recommended Posts

I have foreach method. This displays the choices that are selected and the value inside them as 1.  The method is shown below. I am printing these with the name(choice1, choice2, choice3, choic4) and the value. If there is a value then it prints 1.  Now my problem is I want to INSERT them into my database. if it prints choice1, choice2 then value 1 must be entered into choice1 and choice2 inside the database. I am not sure how to do this. can someone help me.

foreach ($_POST["choice"] as $question => $answer) 

	if($answer == NULL) 
		 $val = 1;

	echo "choice id: $question. value: $val <br />";

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.

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.