我有一个包含三个部分的表格;级别 1、级别 2 和级别 3。每个部分都包含四个文本区域和一个单选组,每个文本区域旁边都有单选按钮:
<form action="" method="post" name="form" id="form" onSubmit="return validate();">
<table width="123%" border="0" cellpadding="5">
<th colspan="6">
<div align="center"><strong>Level 1</strong></div> </th>
<tr>
<td valign="top"><strong>Pathway</strong></td>
<td colspan="2"><strong>Blocking or Accepting Comment</strong></td>
<td valign="top"><strong>Appropriate</strong></td>
</tr>
<tr>
<td width="26%" valign="top"><strong>Pathway 1:</strong> No action - See again</td>
<td colspan="2"><div class="required">
<textarea name="l1_p1_comment" id="l1_p1_comment" cols="35" rows="5"></textarea>
</div></td>
<td width="18%" valign="top"><p>
<input type="radio" name="l1_allowed" value="1" id="l1_allowed_0" />
</td>
</tr>
<tr>
<td valign="top"><strong>Pathway 2:</strong> See again</td>
<td colspan="2"><div class="required">
<textarea name="l1_p2_comment" id="l1_p2_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l1_allowed" value="1" id="l1_allowed_1" /></td>
</tr>
<tr>
<td valign="top"><strong>Pathway 3:</strong> Refer to ED</td>
<td colspan="2"><div class="required">
<textarea name="l1_p3_comment" id="l1_p3_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l1_allowed" value="1" id="l1_allowed_2" /></td>
</tr>
<tr>
<td valign="top"><strong>Pathway 4:</strong> Refer to Specialist</td>
<td colspan="2"><div class="required">
<textarea name="l1_p4_comment" id="l1_p4_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l1_allowed" value="1" id="l1_allowed_3" /></td>
</tr>
<tr>
<td valign="top"> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
<th colspan="6">
<div align="center"><strong>Level 2</strong></div> </th>
<tr>
<td valign="top"><strong>Pathway</strong></td>
<td colspan="2"><strong>Blocking or Accepting Comment</strong></td>
<td valign="top"><strong>Appropriate</strong></td>
</tr>
<tr>
<td width="26%" valign="top"><strong>Pathway 1:</strong> No action - See again</td>
<td colspan="2"><div class="required">
<textarea name="l2_p1_comment" id="l2_p1_comment" cols="35" rows="5"></textarea>
</div></td>
<td width="18%" valign="top"><p>
<input type="radio" name="l2_allowed" value="1" id="l2_allowed_0" />
</td>
</tr>
<tr>
<td valign="top"><strong>Pathway 2:</strong> See again</td>
<td colspan="2"><div class="required">
<textarea name="l2_p2_comment" id="l2_p2_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l2_allowed" value="1" id="l2_allowed_1" /></td>
</tr>
<tr>
<td valign="top"><strong>Pathway 3:</strong> Refer to ED</td>
<td colspan="2"><div class="required">
<textarea name="l2_p3_comment" id="l2_p3_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l2_allowed" value="1" id="l2_allowed_2" /></td>
</tr>
<tr>
<td valign="top"><strong>Pathway 4:</strong> Refer to Specialist</td>
<td colspan="2"><div class="required">
<textarea name="l2_p4_comment" id="l2_p4_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l2_allowed" value="1" id="l2_allowed_3" /></td>
</tr>
<tr>
<td valign="top"> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
<th colspan="6">
<div align="center"><strong>Level 3</strong></div> </th>
<tr>
<td valign="top"><strong>Pathway</strong></td>
<td colspan="2"><strong>Blocking or Accepting Comment</strong></td>
<td valign="top"><strong>Appropriate</strong></td>
</tr>
<tr>
<td width="26%" valign="top"><strong>Pathway 1:</strong> No action - See again</td>
<td colspan="2"><div class="required">
<textarea name="l3_p1_comment" id="l3_p1_comment" cols="35" rows="5"></textarea>
</div></td>
<td width="18%" valign="top"><p>
<input type="radio" name="l3_allowed" value="1" id="l3_allowed_0" />
</td>
</tr>
<tr>
<td valign="top"><strong>Pathway 2:</strong> See again</td>
<td colspan="2"><div class="required">
<textarea name="l3_p2_comment" id="l3_p2_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l3_allowed" value="1" id="l3_allowed_1" /></td>
</tr>
<tr>
<td valign="top"><strong>Pathway 3:</strong> Refer to ED</td>
<td colspan="2"><div class="required">
<textarea name="l3_p3_comment" id="l3_p3_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l3_allowed" value="1" id="l3_allowed_2" /></td>
</tr>
<tr>
<td valign="top"><strong>Pathway 4:</strong> Refer to Specialist</td>
<td colspan="2"><div class="required">
<textarea name="l3_p4_comment" id="l3_p4_comment" cols="35" rows="5"></textarea>
</div></td>
<td valign="top"><input type="radio" name="l3_allowed" value="1" id="l3_allowed_3" /></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><input type="submit" name="submit" id="submit" value="Create Pathways for All Levels" /></td>
<td> </td>
</tr>
</table>
</form>
提交时,有多个插入:
$l1_p1_comment = $_POST['l1_p1_comment'];
$l1_p2_comment = $_POST['l1_p2_comment'];
$l1_p3_comment = $_POST['l1_p3_comment'];
$l1_p4_comment = $_POST['l1_p4_comment'];
$l2_p1_comment = $_POST['l2_p1_comment'];
$l2_p2_comment = $_POST['l2_p2_comment'];
$l2_p3_comment = $_POST['l2_p3_comment'];
$l2_p4_comment = $_POST['l2_p4_comment'];
$l3_p1_comment = $_POST['l3_p1_comment'];
$l3_p2_comment = $_POST['l3_p2_comment'];
$l3_p3_comment = $_POST['l3_p3_comment'];
$l3_p4_comment = $_POST['l3_p4_comment'];
$l1_allowed = $_POST['l1_allowed'];
$l2_allowed = $_POST['l2_allowed'];
$l3_allowed = $_POST['l3_allowed'];
if(isset($_POST['submit'])){
$query =
"INSERT INTO pathway
(pathway_pk, case_fk, level, pathway_allowed, comment, created, created_by)
VALUES
('', '$case_fk', '1', '$l1_allowed', '$l1_p1_comment', NOW(), '$author_pk'),
('', '$case_fk', '1', '$l1_allowed', '$l1_p2_comment', NOW(), '$author_pk'),
('', '$case_fk', '1', '$l1_allowed', '$l1_p3_comment', NOW(), '$author_pk'),
('', '$case_fk', '1', '$l1_allowed', '$l1_p4_comment', NOW(), '$author_pk'),
('', '$case_fk', '2', '$l2_allowed', '$l2_p1_comment', NOW(), '$author_pk'),
('', '$case_fk', '2', '$l2_allowed', '$l2_p2_comment', NOW(), '$author_pk'),
('', '$case_fk', '2', '$l2_allowed', '$l2_p3_comment', NOW(), '$author_pk'),
('', '$case_fk', '2', '$l2_allowed', '$l2_p4_comment', NOW(), '$author_pk'),
('', '$case_fk', '3', '$l3_allowed', '$l3_p1_comment', NOW(), '$author_pk'),
('', '$case_fk', '3', '$l3_allowed', '$l3_p2_comment', NOW(), '$author_pk'),
('', '$case_fk', '3', '$l3_allowed', '$l3_p3_comment', NOW(), '$author_pk'),
('', '$case_fk', '3', '$l3_allowed', '$l3_p4_comment', NOW(), '$author_pk')
";
$result = mysql_query($query, $connection) or die(mysql_error());
现在,我想让三个部分(第 1 级、第 2 级和第 3 级)中的每一个的无线电组为选定的无线电提交值“1”(即允许),每个组中的其他无线电提交“0”从:
$l1_allowed = $_POST['l1_allowed'];
$l2_allowed = $_POST['l2_allowed'];
$l3_allowed = $_POST['l3_allowed'];
关于如何做到这一点的任何建议?