表单提交的变量不检索数据

时间:2016-11-28 15:30:51

标签: php html mysql fpdf

虽然我在这里找不到问题的解决方案,但我想发布这个。当尝试从表单提交的变量module fourBitCounter (input clk, output [3:0]counter ); wire clk; initial begin reg[3:0] counter = 4'b1; end always@ (posedge clk) begin if(counter > 15) counter <= 0; else counter <= counter + 1; end endmodule 中检索数据时,它不起作用。

sales.php

$receiptNo

salesreceipt.php

<input name="txtReceiptNo" type="text" id="txtReceiptNo" size="10" value="<?php $receiptNo = mysqli_fetch_row(mysqli_query($connection,"SELECT max(sales_id)+1 FROM sales")); echo $receiptNo[0];?>" readonly />    

但是,当尝试为if(isset($_POST['txtReceiptNo'])){ $receiptNo = $_POST['txtReceiptNo']; } $result=mysqli_query($connection,"SELECT I.item_name, S.qty, S.unit_price, S.amount, S.date,S.receipt_no, S.discount, U.username FROM sales S INNER JOIN items I ON S.item_id=I.item_id INNER JOIN users U ON S.user_id=U.id WHERE S.receipt_no=$receiptNo"); 提供数据库值时,它会检索数据。

$receiptNo

enter image description here

非常感谢任何帮助。

fpdf代码段($result=mysqli_query($connection,"SELECT I.item_name, S.qty, S.unit_price, S.amount, S.date,S.receipt_no, S.discount, U.username FROM sales S INNER JOIN items I ON S.item_id=I.item_id INNER JOIN users U ON S.user_id=U.id WHERE S.receipt_no=324"); ):

salesreceipt.php

enter image description here

1 个答案:

答案 0 :(得分:0)

我找到了解决方法。

调用form按钮时没有PROCEED次提交。只有一个onclick事件可以打开一个窗口,如下所示:

<input type="submit" name="btnPrintReceipt" id="btnPrintReceipt" value="PRINT &amp; PROCEED" onclick="window.open('<?php echo BASE_URL?>reports/salesreceipt2.php','popup','width=1200,height=900'); return false;"/>

我改为:

<input type="button" name="btnPrintReceipt" id="btnPrintReceipt" value="PRINT &amp; PROCEED" onclick="printProceed(true, txtReceiptNo.value);resetformTotal();"/>

并添加了ajax来电。

function printProceed(isPrint, recordId){

              var listCustomer = document.getElementById("listCustomer").value;
              var txtReceiptNo = document.getElementById("txtReceiptNo").value;
              var staff = document.getElementById("staff").value;
              var discount = document.getElementById("discount").value;
              var txtSubTotal = document.getElementById("txtSubTotal").value;
              var txtGrossTotal = document.getElementById("txtGrossTotal").value;

              // Returns successful data submission message when the entered information is stored in database.
              var dataString = {listCustomer: listCustomer, txtReceiptNo: txtReceiptNo, staff: staff, discount: discount};
              if (listCustomer == ''|| txtReceiptNo == ''|| staff == ''|| discount == '') {
              salesitemsAddFail();
              } 
              else {

$.ajax({
       type: "POST",
       url: "/pms/includes/functions/sales_functions.php",
       data: dataString,
       cache: false,
       //includes/functions/sales_functions.php
       success:function(html){
            if(isPrint == true){
            printpdf(recordId,txtSubTotal,txtGrossTotal,discount);
        }
       }

                         //reload the sales datagrid once add the item details to temporary table (sales_temp)
                 //window.location.reload();
                 //refresh/update the sub total value when adding

       });

                  $('#list').trigger("reloadGrid",[{page:1}]);
                  $("#sub_total_div").load(location.href + " #sub_total_div");

}}