PHP inserting

I have a form… which is automatically generated from a mysql select query.

Some forms only have 5 insert boxes, some have 8.

What would be the best way to count how many things have been posted for the form and insert them?

I need to insert a new row for each form field submitted for this… and I need a way to know how many fields have been posted and insert that many rows accordingly with the correct values.

For example:

http://ethug.net/nrl/style.php?round=1 - Has 8 form select boxes, but some can have 5.

I don’t know if you will even understand any of that :stuck_out_tongue:

Any help is greatly appreciated.

use name=“tip” and you will get the values as an array

I still don’t know how to do a certain amount of insert queries… depending on how many forms field have been submitted.

foreach($_POST[‘tip’]) {
// do things
}

Does this look good?


foreach ($_POST as $key => $value) {
	if (preg_match("/choice/i", $key)) {
    		$fixture = explode("choice_", $key);
    		$fid = $fixture[1];
    		$f_value = $value;
    		echo "<br />".$fid." - ".$f_value."<br />";
	}
}

This thread may help Kyle.

You name your fields as choice
<input name=“choice”>

This will give you an array of “choices” in the $_POST. Use var_dump to see the results. Then you can just foreach($_POST[‘choices’] as $choice) and it doesn’t matter how many.