我正在尝试学习如何编程,这是我的第一个项目。我知道我应该阅读教程,但我有点坚持。真的很想自己完成它,但是越来越令人沮丧..至少有人可以引导我朝着正确的方向前进吗?那么,如何根据下拉列表选择将数据回显到表格单元格?非常感谢任何帮助。到目前为止的代码:http: //jsfiddle.net/uFEPn/3/
<select>
<option>-- Select lot --</option>
<?php
mysql_connect('localhost','root','');
mysql_select_db('pl_base');
$query="SELECT DISTINCT lot_number FROM pl_table";
$result=mysql_query($query);
while(list($lot_number)=mysql_fetch_row($result)) {
echo "<option value=\"".$lot_number."\">".$lot_number."</option>";
}
?>
</select>
</br>
<table border="1" id="table">
<tr>
<th width=80 height=30>Lot<br/>number</th>
<th width=110 height=30>Description</th>
<th width=90 height=30>Pallet<br/>number</th>
<th width=60 height=30>Net</th>
<th width=60 height=30>Gross</th>
</tr>
<tr>
<td>#</td>
<td rowspan="5">echo results here</td>
<td><b>Total</b></td>
<td>#</td>
<td>#</td>
</tr>
<td> # </td>
<td colspan="3">#</td>
</tr>
<tr>
<th>&</th>
<th>&</th>
<th>&</th>
<th>&</th>
</tr>
</table>
数据库中的表:
+--------------------------+-------------------------+---------+-------+
| id | lot_number | descr | pallet_number | net | gross |
+--------------------------+-------------------------+---------+-------+
| 1 | 111 | black | 1 | 800 | 900 |
| 2 | 111 | black | 2 | 801 | 901 |
| 3 | 111 | black | 3 | 802 | 902 |
| 4 | 222 | white | 1 | 800 | 900 |
| 5 | 222 | white | 2 | 801 | 901 |
| 6 | 222 | white | 3 | 802 | 902 |
+--------------------------+-------------------------+---------+-------+