只有 html 表的最后一行被插入到数据库中 [英] only last row of the html table gets inserted into database
本文介绍了只有 html 表的最后一行被插入到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
账单.php
<头><title>帐单页</title><link rel="stylesheet" type="text/css" href="bill.css">头部><body onload="start()"><script src="bill.js"></script><form name='adminform' method='post' action="billdb.php" onload="return start()"><input type="text" style="position: absolute;top:100px;"value="<?php echo $tnumber ?>"><div id="日期"></div><div id="时钟"></div><label id="billno">账单编号:</label><label id="items">Items</label><label id="数量">数量</label><label id="price">价格</label><label id="amount">Amount</label><label id="tax">服务税</label><label id="total">Total</label><?phpwhile($row= mysqli_fetch_array($res2)){//$title=$row['title'];echo "<表格样式>";echo "";回声<td id='td1'>".$row['subtitle'] ;echo "<input type='hidden' name='subtitle' value='{$row['subtitle']}'>";echo " ";echo " ";echo " ";echo " ";echo " ";回声 ";回声 ";回声 $row['数量'] ;echo "<input type='hidden' name='quantity' value='{$row['quantity']}'>";回声 $row['price'];echo "<input type='hidden' name='price' value='{$row['price']}'>";$amount=$row['price'] * $row['quantity'];回声 ";回声 ";echo " ";echo " ";echo " ";echo " ";回声 ";回声 ";回声 ";回声 ";回声 ";回声 ";echo "$amount.0000";echo "";$total=$total+$amount;$total1=$total+50.000;echo "<input type='hidden' name='total' value='{$total}'>";echo "<input type='hidden' name='tax' value='{50.0000}'>";}echo "</table>";$billno=$row4['last_bill'];?><div id="bd"><?php echo $billno ?></div><input type="hidden" name="billno" value="<?php echo $billno?>"><div id="tamt"><?php echo "$total1.0000"?></div><div id="taxamt">50.0000/格<input type="text" name="custno" value="<?php echo $cusno?>"><input type="hidden" name="tnumber" value="<?php echo $tnumber?>"><input type="submit" id="generate" name="generate" value="生成账单"></表单></html><块引用>
billdb.php
require_once('conn.php');$billno=(\filter_input(\INPUT_POST,'billno'));$custno=(\filter_input(\INPUT_POST,'custno'));$tnumber=(\filter_input(\INPUT_POST,'tnumber'));$subtitle=(\filter_input(\INPUT_POST,'subtitle'));$quantity=(\filter_input(\INPUT_POST,'quantity'));$price=(\filter_input(\INPUT_POST,'price'));$amount=(\filter_input(\INPUT_POST,'amount'));$tax=(\filter_input(\INPUT_POST,'tax'));$total=(\filter_input(\INPUT_POST,'total'));$sql="insert into billmgmt(billno,custno,tnumber,subtitle,quantity,price,amount,tax,total)values('$billno','$c ustno','$tnumber','$subtitle','$quantity','$price','$amount','$tax','$total')" 或 die(mysqli_error($dbhandle));$res= mysqli_query($dbhandle,$sql);echo "成功";mysqli_close($dbhandle);
<块引用>
我已将 mysql 数据库中的内容检索到 html 表中,我需要将 html 表中的值存储在 billmgmt 表中.但是 html 表的最后一行值单独存储,使用此代码.请帮帮我.........
解决方案 用这个代替你的.
echo "";echo "<input type='hidden' name='quantity' value='".$row['quantity']."'>";
和其他输入一样,只需像这样更改它们.
bill.php
<html>
<head>
<title>Bill Page</title>
<link rel="stylesheet" type="text/css" href="bill.css">
</head>
<body onload="start()">
<script src="bill.js"></script>
<form name='adminform' method='post' action="billdb.php" onload="return start()">
<input type="text" style="position: absolute;top:100px;" value="<?php echo $tnumber ?>">
<div id="date"></div>
<div id="clock"></div>
<label id="billno">Bill No:</label>
<label id="items">Items</label>
<label id="quantity">Quantity</label>
<label id="price">Price</label>
<label id="amount">Amount</label>
<label id="tax">Service Tax</label>
<label id="total">Total</label>
<?php
while($row= mysqli_fetch_array($res2))
{
// $title=$row['title'];
echo "<table style>";
echo "<tr>";
echo "<td id='td1'>" .$row['subtitle'] ;
echo "<input type='hidden' name='subtitle' value= '{$row['subtitle']}'>";
echo " ";echo " ";echo " ";echo " ";echo " ";
echo " ";echo " ";
echo $row['quantity'] ;
echo "<input type='hidden' name='quantity' value= '{$row['quantity']}'>";
echo $row['price'];
echo "<input type='hidden' name='price' value= '{$row['price']}'>";
$amount=$row['price'] * $row['quantity'];
echo " ";echo " "; echo " ";echo " ";echo " ";echo " "; echo " ";echo " ";
echo " ";echo " "; echo " ";echo " ";
echo "$amount.0000</td>";
echo "<input type='hidden' name='amount' value= '{$amount}'>";
$total=$total+$amount;
$total1=$total+50.000;
echo "<input type='hidden' name='total' value= '{$total}'>";
echo "<input type='hidden' name='tax' value= '{50.0000}'>";
}
echo "</table>";
$billno=$row4['last_bill'];
?>
<div id="bd"><?php echo $billno ?></div>
<input type="hidden" name="billno" value="<?php echo $billno?>">
<div id="tamt"><?php echo "$total1.0000"?></div>
<div id="taxamt"> 50.0000</div>
<input type="text" name="custno" value="<?php echo $cusno?>">
<input type="hidden" name="tnumber" value="<?php echo $tnumber?>">
<input type="submit" id="generate" name="generate" value="Generate Bill">
</form>
</body>
</html>
billdb.php
require_once('conn.php');
$billno=(\filter_input(\INPUT_POST,'billno'));
$custno=(\filter_input(\INPUT_POST,'custno'));
$tnumber=(\filter_input(\INPUT_POST,'tnumber'));
$subtitle=(\filter_input(\INPUT_POST,'subtitle'));
$quantity=(\filter_input(\INPUT_POST,'quantity'));
$price=(\filter_input(\INPUT_POST,'price'));
$amount=(\filter_input(\INPUT_POST,'amount'));
$tax=(\filter_input(\INPUT_POST,'tax'));
$total=(\filter_input(\INPUT_POST,'total'));
$sql="insert into billmgmt(billno,custno,tnumber,subtitle,quantity,price,amount,tax,total)values('$billno','$c ustno','$tnumber','$subtitle','$quantity','$price','$amount','$tax','$total')" or die(mysqli_error($dbhandle));
$res= mysqli_query($dbhandle,$sql);
echo "success";
mysqli_close($dbhandle);
I have retrieved the contents from mysql database into html table,From html table i need to store the values in a billmgmt table.but the last row values of html table alone gets stored,with this code.Please help me out .........
解决方案 use this instead of yours.
echo "<input type='hidden' name='subtitle' value= '".$row['subtitle']."'>";
echo "<input type='hidden' name='quantity' value= '".$row['quantity']."'>";
and same for other inputs , just change them like that.
这篇关于只有 html 表的最后一行被插入到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录
关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆