Thanks. Yes that is a big help. The radio button is actually not used for that purpose (sorry that was a bit confusing of me to put in without an explanation). For each person selected, the radio button Y/N relates to whether they are an author of the report or just a contributer. I assume, the radio button can be handled the same way and I can just extrapolate your example to figure that out - I think ;)

- Charles

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