【发布时间】:2012-02-06 16:49:28
【问题描述】:
我需要一些帮助,
我有一个带有下拉列表的 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>
【问题讨论】:
标签: php mysql ajax dynamic refresh