我需要一些帮助,请,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