John, 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>
</select>
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.
["investigator"]=> array(2) { ["person"]=> string(10) "1033592151" ["yesno"]=> string(1) "Y" }
How would I apply your 'how-to' to this? I have gotten stuck now.
Thanks again, 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 exampleofthe form.type="radio"
<form> <select name="person1"> <option value="1">Joe Smith</option> etc. </select> <input type="radio" name="person1yn" value="Yes"> Y <inputname="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.
<form> <select name="person[]"> <option value="0">Choose Person</option> <option value="1">Joe Smith</option> ... </select>
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
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php