0
這可能有一個簡單的解決方案,但我很難倒在這裏。正如您在下面看到的,我希望員工能夠以一種形式請求多達6個不同的項目。我面臨的問題是,如何在各自的列中存儲6個可能的值(項目編號,Ited描述,請求數量和請求目的)?我可以使用數組,但這隻會使它更復雜。用用戶輸入插入表格
這是我的表說明:
+--------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+----------------+
| Request_Number | int(11) | NO | PRI | NULL | auto_increment |
| Request_Date | date | NO | | NULL | |
| Department | varchar(30) | NO | | NULL | |
| Email | varchar(80) | NO | | NULL | |
| Item_Number | int(11) | YES | | NULL | |
| Item_Description | varchar(250) | YES | | NULL | |
| Quantity_Requested | varchar(20) | YES | | NULL | |
| Request_Purpose | varchar(255) | YES | | NULL | |
| Sub_Dept_Head | varchar(50) | YES | | NULL | |
| Dept_Head | varchar(50) | YES | | NULL | |
| Admin_Dept | varchar(50) | YES | | NULL | |
| Approved_By | varchar(50) | YES | | NULL | |
+--------------------+--------------+------+-----+---------+----------------+
這是形式:
<form class="Requisition_form" id="form1" name="form1" method="post" action="">
<table width="100%" border="2" cellspacing="0" cellpadding="5">
<tr>
<th colspan="7">Personal Detail:</th>
</tr>
<tr>
<td width="155"><strong>Request Date:</strong></td>
<td width="199"><label>
<input size="30" type="date" name="date" id="date" placeholder="yyyy/mm/dd"/>
</label></td>
<td width="133"><strong>Department</strong></td>
<td width="182"><label>
<input size="30" type="text" name="department" id="department" />
</label></td>
</tr>
<tr>
<td><strong>Requested By:</strong></td>
<td><label>
<input size="30" type="text" name="requested_by" id="requested_by" />
</label></td>
<td><strong>E-Mail:</strong></td>
<td><label>
<input size="30" type="email" name="email" id="email" />
</label></td>
</tr>
</table>
<table width="100%" border="2" cellspacing="0" cellpadding="5">
<tr>
<th colspan="4">Requisition Detail:</th>
</tr>
<tr>
<td width="25%" align="center"><strong>Item Number</strong></td>
<td width="25%" align="center"><strong>Item Description</strong></td>
<td width="25%" align="center"><strong>Quantity Requested</strong></td>
<td width="25%" align="center"><strong>Request Purpose</strong></td>
</tr>
<tr>
<td align="center"><label>
<input size="30" type="text" name="item_number" id="item_number" />
</label></td>
<td align="center"><label>
<input size="30" type="text" name="item_description" id="item_description" />
</label></td>
<td align="center"><label>
<input size="30" type="text" name="qty_requested" id="qty_requested" />
</label></td>
<td align="center"><label>
<input size="30" type="text" name="request_purpose" id="request_purpose" />
</label></td>
</tr>
<tr>
<td align="center"><input size="30" type="text" name="item_number2" id="item_number2" /></td>
<td align="center"><input size="30" type="text" name="item_description2" id="item_description2" /></td>
<td align="center"><input size="30" type="text" name="qty_requested2" id="qty_requested2" /></td>
<td align="center"><input size="30" type="text" name="request_purpose2" id="request_purpose2" /></td>
</tr>
<tr>
<td align="center"><input size="30" type="text" name="item_number3" id="item_number3" /></td>
<td align="center"><input size="30" type="text" name="item_description3" id="item_description3" /></td>
<td align="center"><input size="30" type="text" name="qty_requested3" id="qty_requested3" /></td>
<td align="center"><input size="30" type="text" name="request_purpose3" id="request_purpose3" /></td>
</tr>
<tr>
<td align="center"><input size="30" type="text" name="item_number4" id="item_number4" /></td>
<td align="center"><input size="30" type="text" name="item_description4" id="item_description4" /></td>
<td align="center"><input size="30" type="text" name="qty_requested4" id="qty_requested4" /></td>
<td align="center"><input size="30" type="text" name="request_purpose4" id="request_purpose4" /></td>
</tr>
<tr>
<td align="center"><input size="30" type="text" name="item_number5" id="item_number5" /></td>
<td align="center"><input size="30" type="text" name="item_description5" id="item_description5" /></td>
<td align="center"><input size="30" type="text" name="qty_requested5" id="qty_requested5" /></td>
<td align="center"><input size="30" type="text" name="request_purpose5" id="request_purpose5" /></td>
</tr>
<tr>
<td align="center"><input size="30" type="text" name="item_number6" id="item_number6" /></td>
<td align="center"><input size="30" type="text" name="item_description6" id="item_description6" /></td>
<td align="center"><input size="30" type="text" name="qty_requested6" id="qty_requested6" /></td>
<td align="center"><input size="30" type="text" name="request_purpose6" id="request_purpose6" /></td>
</tr>
</table>
<table width="100%" border="2" cellspacing="0" cellpadding="5">
<tr>
<th colspan="4">Recommendations:</th>
</tr>
<tr>
<td align="center"><strong>Sub-Department Head</strong></td>
<td align="center"><strong>Department Head</strong></td>
<td align="center"><strong>Administration</strong></td>
<td align="center"><strong>Approved by</strong></td>
</tr>
<tr>
<td align="center"><input size="30" type="text" name="sub_dept_head" id="sub_dept_head" /></td>
<td align="center"><input size="30" type="text" name="dept_head" id="dept_head" /></td>
<td align="center"><input size="30" type="text" name="admin_dept" id="admin_dept" /></td>
<td align="center"><input size="30" type="text" name="approved_by" id="approved_by" /></td>
</tr>
</table>
</form>
「我可以使用數組但只會讓問題更加複雜。」它會怎樣?我認爲這是一個使用 – 2014-11-05 10:24:01
+1 @DavidJones的完美場景。如果有任何使用數組的理由,這就是一個很好的例子。 – ThisBoyPerforms 2014-11-05 10:30:22