我有 1 个名为 sales 的表,其中的 ff 字段是
编号 | 总字段 | 1 | 100 |
现在我的问题是如何将文本框中的值乘以表的值,即“total_fields”。我想要的是,当我在第 60 行从我的文本框中输入值并单击第 66 行上的updatesale.php 时,我的总值“total_fields”必须乘以我在文本框中输入的值。所以如果我输入 2“total_fields”必须是 200,如果我输入 3“total_fields”必须是 300。我尝试了我所学的任何东西,但我无法得到我想要的东西。任何想法对我都非常有帮助。
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("inventory", $con);
$f=$_SESSION['SESS_MEMBER_ID'];
$result = mysql_query("SELECT * FROM sales where code = '".$f."' GROUP BY pcode");
function formatMoney($number, $fractional=false) {
if ($fractional) {
$number = sprintf('%.2f', $number);
}
while (true) {
$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
if ($replaced != $number) {
$number = $replaced;
} else {
break;
}
}
return $number;
}
while($row = mysql_fetch_array($result))
{
$pcode = $row['pcode'];
$totalretail = 0;
$qty_tot = 0;
$rr_tot = 0;
$vats_tot = 0;
$final_tot = 0;
$item_amount = 0;
$result_info = mysql_query("SELECT * FROM sales where pcode = '".$pcode."'");
while($row_info = mysql_fetch_array($result_info)){
$name = $row_info['name'];
$qty = $row_info['qty'];
$ppp=$row_info['PRICE'];
$rr=$row_info['total'];
$id = $row_info["id"];
$vats = $row_info["vats"];
$percent = $row_info["percent"];
$qty_tot += $qty;
$rr_tot += $ppp;
$item_amount += $ppp;
$totalretail += $rr;
$vats_tot += $vats;
}
echo '<tr>';
echo '<td style = "background-image:url(images/buts1.png);border:0px;"><div align="center" style = "color:black">'.$pcode.'</div></td>';
echo '<td style = "background-image:url(images/buts1.png);border:0px;><div align="center" > '.$name.'</div></td>';
echo '<td style = "background-image:url(images/buts1.png);border:0px;><div align="center">'.$qty_tot.'</div></td>';
echo '</div></td>';
echo '<td>'.$vats_tot.'</td>';
echo '<input type = "text" name = "multiply" style = "width:30px;"/>';
echo '</div></td>';
echo '<td style = "border:0px;background-image:url(images/buts1.png)">';
echo formatMoney ($totalretail , true);
echo '</div></td>';
echo '<td style = "background-image:url(images/buts1.png);border:0px;">';
echo '<a href=updatesales.php?id=' . $row["id"] .'>update |</a>';
echo '<a href=delete.php?id=' . $row["id"] .'>Cancel</a>';
echo '</td>';
echo '</tr>';
}
mysql_close($con);
?>