RE: INSERT Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

you need to create 5 selects, all named investigator[] with index 1-5 (or
0-4), with the option set to empty for no selection.

this will return an array
investigator[1] => '1064618047'
investigator_yesno[1] => 'Y'

investigator[2] => '1649815377'
investigator_yesno[2] => 'N'

for example


<form>
<table>
<tr>
	<td>
	<select name="investigator[1]">
	<option value="">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[1]" value="Y" type="radio"
	checked="checked" />Yes
	<input name="investigator_yesno[1]" value="N" type="radio" />No
	</td>
</tr>
<tr>
	<td>
	<select name="investigator[2]">
	<option value="">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[2]" value="Y" type="radio"
	checked="checked" />Yes
	<input name="investigator_yesno[2]" value="N" type="radio" />No
	</td>
</tr>
...more here ....
</table>
</form>



on the script receiving the data you  then need a for loop to insert the
records, one for each person


for ($i = 1; $i <= 4; $i++)
{
//only do it if there is a value for $investigator[$i], ie there is a
selection
if($investigator[$i]) {
    $query = 'INSERT INTO tbl_report_people
                (record_id
                , person_id
                , investigator_yesno
                )
                VALUES
                ("'.$record_id[$i].'"
                , "'.$investigator[$i].'"
                , "'.$investigator_yesno[$i].'"
                )
                                ';
    $mysql_result = mysql_query($query, $mysql_link);

    }//end if

}//end for



hope this helps

Peter







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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux