I modified my form, but not having much luck.

Here is my new form (so far):

** I need to add 4 more selects, not sure how to name them **

<select name="investigator[person]">
<option value="0">Choose person</option>
<option value="1064618047">Paul A</option>
<option value="1655387822">Katrina A</option>
<option value="1649815377">David A</option>
is a primary investigator?
<input name="investigator[yesno]" value="Y" type="radio" checked="checked" />Yes
<input name="investigator[yesno]" value="N" type="radio" />No

When I submit this form and do a print_r() on the array this is what I get.

  array(2) {
    string(10) "1033592151"
    string(1) "Y"

How would I apply your 'how-to' to this? I have gotten stuck now.

Thanks again,

On Saturday, March 29, 2003, at 05:46 PM, John W. Holmes wrote:

Since I don't totally understand (newbie) I will show you an example
the form.

<select name="person1">
<option value="1">Joe Smith</option>
<input type="radio" name="person1yn" value="Yes"> Y <input
name="person1yn" value="No"> N

So if the 'Y' radio button is chosen, you'll want to take that 'person' and input them into the table?

First, the easy way would be to lose the radio button and just put a
"Choose Person" option in the <select> dropdown. Then, only process the
names if it's not "Choose Person"...

Even if you can't lose the radio buttons, you'll need to make everything
arrays so they are easier to process.

<select name="person[]">
<option value="0">Choose Person</option>
<option value="1">Joe Smith</option>

Then, to process that (assuming POST) you'd use:

Foreach($_POST['person'] as $person_id)
        if($person_id > 0)
        { $insert[] = "('$person_id')"; }
$sql = "INSERT INTO table (person_id) VALUES " . implode(',',$insert);

Then run $sql... The second part loops through each "person" select and
makes sure the value isn't zero before it creates the ('value') part of
the SQL. The implode() at the end of the $sql line takes each ('value')
part and joins them into a string separated by a comma.

Does that help at all?

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to