php - 只有 html 表的最后一行被插入到数据库中

标签 php mysql

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 "&nbsp";echo "&nbsp";echo "&nbsp";echo "&nbsp";echo "&nbsp";
     echo "&nbsp";echo "&nbsp";
     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 "&nbsp";echo "&nbsp"; echo "&nbsp";echo "&nbsp";echo "&nbsp";echo "&nbsp"; echo "&nbsp";echo "&nbsp";
echo "&nbsp";echo "&nbsp"; echo "&nbsp";echo "&nbsp";
  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 .........

最佳答案

用这个代替你的。

   echo "<input type='hidden' name='subtitle'  value= '".$row['subtitle']."'>";


   echo "<input type='hidden' name='quantity'  value= '".$row['quantity']."'>";

其他输入也一样,只是这样改变它们。

关于php - 只有 html 表的最后一行被插入到数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23181078/

相关文章:

mysql - mssql转mysql出错

php - 为每个帐户或几个大表动态创建 mysql 表

PHP/LDAP : Bad Search Filter (OU with Ampersand)

php - 按钮点击计数器[PHP]

C#、MySql Select语句

两台服务器访问MySQL单DB

mysql - 在 MySQL 对表进行分区时,这里如何使用 DIV 作为 HASH 分区定义的一部分?

php - 在 PDO 准备语句中将值传递给 MySQL IN 操作?

php - 无法识别我在 PHP 中进行的查询中的 MySQL 错误

php - Laravel - 传递多个变量以查看