比尔.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>

比尔DB.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);

我已经从mysql数据库中检索到了html表中的内容,从html表中我需要将这些值存储在billmgmt表中,但是只有html表的最后一行值是用这段代码存储的,请帮助我。。。。。。。。。

最佳答案

用这个代替你的。

   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/

10-13 00:59