> Since I don't totally understand (newbie) I will show you an example
> the form.
> <form>
> <select name="person1">
> <option value="1">Joe Smith</option>
> etc.
> </select>
> <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
today. http://www.phparch.com/

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to