是否有合适的方法根据SELECT中的结果获取输入表单?我有这个,但当它被发布到下一页时,只显示最后一个结果。
<?php
$query = sprintf("SELECT promocost FROM Items, Promotions, Vendor_Prices, Vendors
WHERE Items.itemid = Promotions.itemid AND
Vendors.vendorid = Promotions.vendorid AND
Vendor_Prices.vendorid = Vendors.vendorid AND
Vendor_Prices.itemid = Items.itemid AND
promoid = '$promoid'");
$result =mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while($row = mysql_fetch_assoc($result)) {
$models = $row['promocost'];
echo "<input type='text' name='promocost[]'/>";
}
?>
编辑: 拿出不必要的变量。
<?php
$query = sprintf("SELECT promocost FROM Items, Promotions, Vendor_Prices, Vendors
WHERE Items.itemid = Promotions.itemid AND
Vendors.vendorid = Promotions.vendorid AND
Vendor_Prices.vendorid = Vendors.vendorid AND
Vendor_Prices.itemid = Items.itemid AND
promoid = '$promoid'");
$result =mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while($row = mysql_fetch_assoc($result)) {
echo "<input type='text' name='promocost[]'/>";
}
?>