Jump to content

foreach method


xxreenaxx1

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=0; 
	}
		else{
		 $val = 1;
		 }

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

Link to comment
https://forums.phpfreaks.com/topic/230636-foreach-method/
Share on other sites

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.