我有一個表格,它有三個部分;級別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'];
關於如何做到這一點的任何建議?
謝謝,但是這並沒有回答我的問題。順便說一句,表單提交到當前頁面......沒有問題做插入,只需要建議如何處理多個插入的無線電溝通... validate()是一個js scipt來驗證窗體...不包括在上面的代碼中不相關。 – IlludiumPu36 2013-02-28 03:19:49