我需要一些幫助,請,MySQL數據 - 下拉列表
我有一個PHP頁面下拉列表,通過MySQL數據庫查詢填充。 我希望能夠顯示其他表格單元格中所選選項的數據庫詳細信息。理想情況下,這可以在沒有頁面刷新的情況下實現。
除了這個表將包括多達75行的(貨盤上的車輛 - 這是一個銷售工具),所以需要有一個while語句或東西達致這。每行將有一個選擇框來選擇一個packcode。
我的代碼與下拉列表如下,該表只包含5行現在。
我知道我需要使用ajax或JavaScript除此之外?
如果任何人有一個示例腳本或可以使用我的代碼作爲例子,我真的很感激它。
<?
$con = mysql_connect("localhost","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("dbname", $con);
$packcodesql="SELECT packcode from skudata order by packcode";
$resultpackcode=mysql_query($packcodesql);
$optionspackcode="";
while ($row=mysql_fetch_array($resultpackcode)) {
$packcode=$row["packcode"];
$optionspackcode.="<OPTION VALUE=\"$packcode\">".$packcode;
}
?>
<table border=1>
<tr>
<td>Pack Code</td>
<td>Category</td>
<td>Selling Units</td>
<td>Full Pallet QTY</td>
<td>Order QTY</td>
</tr>
<Tr>
<td>
<SELECT NAME=packcode1 style="width:100px;">
<OPTION VALUE=0><?=$optionspackcode?></SELECT>
</td>
<td>
<!-- show mysql result for "select Category from skudata where packcode=packcode1" -->
</td>
<td>
<!-- show mysql result for "select SellingUnits from skudata where packcode=packcode1" -->
</td>
<td>
<!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode1" -->
</td>
<td><input type="text" id="qty" name="qty"></td>
</tr>
<Tr>
<td>
<SELECT NAME=packcode2 style="width:100px;">
<OPTION VALUE=0><?=$optionspackcode?></SELECT>
</td>
<td>
<!-- show mysql result for "select Category from skudata where packcode=packcode2" -->
</td>
<td>
<!-- show mysql result for "select SellingUnits from skudata where packcode=packcode2" -->
</td>
<td>
<!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode2" -->
</td>
<td><input type="text" id="qty" name="qty"></td>
</tr>
<Tr>
<td>
<SELECT NAME=packcode3 style="width:100px;">
<OPTION VALUE=0><?=$optionspackcode?></SELECT>
</td>
<td>
<!-- show mysql result for "select Category from skudata where packcode=packcode3" -->
</td>
<td>
<!-- show mysql result for "select SellingUnits from skudata where packcode=packcode3" -->
</td>
<td>
<!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode3" -->
</td>
<td><input type="text" id="qty" name="qty"></td>
</tr>
<Tr>
<td>
<SELECT NAME=packcode4 style="width:100px;">
<OPTION VALUE=0><?=$optionspackcode?></SELECT>
</td>
<td>
<!-- show mysql result for "select Category from skudata where packcode=packcode4" -->
</td>
<td>
<!-- show mysql result for "select SellingUnits from skudata where packcode=packcode4" -->
</td>
<td>
<!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode4" -->
</td>
<td><input type="text" id="qty" name="qty"></td>
</tr>
</table>
嗨,感謝您花時間回覆。這是我與Ajax的第一次交互,所以如果你能提供更好,更完整的例子,我會很感激。 – Smudger 2012-01-10 09:57:26
當我下班回家時(大約4小時),我們會嘗試擴展這些例子。 與此同時,我建議讀一點關於AJAX;)http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/ – Tehnix 2012-01-10 10:10:25
肯定地, 謝謝,瑞安 – Smudger 2012-01-10 10:39:07