Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在HTML中自动刷新两个表_Javascript_Php_Mysqli_Html Table - Fatal编程技术网

Javascript 无法在HTML中自动刷新两个表

Javascript 无法在HTML中自动刷新两个表,javascript,php,mysqli,html-table,Javascript,Php,Mysqli,Html Table,我想问,为什么我不能刷新两个html表?只有一个?Javascript代码是否有问题?我已经尝试声明2个变量,并尝试为每个变量创建脚本,但仍然没有成功,我尝试将变量名称更改为唯一的变量,但仍然没有成功。我的完整代码如下: <!-- SALES.HTML --> <div class="col-sm-5 shadow"> <p> <h3><center>Hyukies&l

我想问,为什么我不能刷新两个html表?只有一个?Javascript代码是否有问题?我已经尝试声明2个变量,并尝试为每个变量创建脚本,但仍然没有成功,我尝试将变量名称更改为唯一的变量,但仍然没有成功。我的完整代码如下:

    <!-- SALES.HTML -->
    <div class="col-sm-5 shadow">
            <p>
              <h3><center>Hyukies</center></h3>
              <center>Catbalogan, City</center>
              <center><span class="glyphicon glyphicon-time"></span>&nbsp;<?php include('time.php'); ?></center> <br />

               <div id="transactions_left">
                    <?php include_once('salestable.php')?>
                </div>
            </p>

        <div class="row">
                  <div class="col-sm-12"><b>
                      <p>

                    <?php include_once('sales_count.php')?>

                            <script>
                                var table = $("#salestableid");
                                    var refresh = function() {
                                      table.load("salestable.php", function() {
                                        setTimeout(refresh, 1); 
                                      });
                                    };
                                refresh();

                                var table1 = $("#sales_countid");
                                    var refresh1 = function() {
                                      table.load("sales_count.php", function() {
                                        setTimeout(refresh1, 1); 
                                      });
                                    };
                                refresh1();
                            </script>

                        <button type="button" class="btn btn-danger btn-md" data-toggle='modal' data-target='#cancel'>Cancel</a>
                        <button type="button" class="btn btn-warning btn-md" data-toggle='modal' data-target='#hold'>Hold</button>
                        <button type="button" class="btn btn-success btn-md pull-right" data-toggle='modal' data-target='#payment' >Payment</button>
                        <br /><br />
                        <center>Thank you and have a Nice day!</center>

                    </p>
                </div>
        </div>
    </div>

    <!-- End of Page SALES.HTML -->



    <!-- SALESTABLE.PHP -->

        <?php require_once("../includes/db_connection.php"); ?>
               <table class="table table-hover" id='salestableid'>
                    <thead>
                            <tr class= "default" style="background-color: #e18728">
                                <th><font color = "white">Action</font></th>
                                <th width="200"><font color = "white">Product</th>
                                <th><font color = "white">Quantity</th>
                                <th width="75"><font color = "white">Price</th>
                                <th width ="90"><font color = "white">Total</th>
                            </tr>
                    </thead>
                <tbody>
                      <tr>
                                                            <?php
                                                                $user_query = mysqli_query($connection, "SELECT saleslog.itemid, saleslog.qty, saleslog.date, saleslog.total, saleslog.id, items.`name`, items.description, items.retailprice FROM saleslog LEFT JOIN items ON items.id = saleslog.itemid")or die(mysqli_error());
                                                                while($row = mysqli_fetch_array($user_query)){
                                                                $id = $row['id'];
                                                            ?>

                                                        <tr>
                                                            <td><a href="delete_salesitem.php?id=<?php echo urlencode($row['id']); ?>" class="btn btn-danger glyphicon glyphicon-trash btn-xs"></a></td>
                                                            <td><?php echo $row['name']; ?></td>
                                                            <td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<?php echo $row['qty']; ?></td>                   
                                                            <td>&nbsp<?php echo number_format($row['retailprice'],2); ?></td>
                                                            <?php 
                                                                $total = $row['qty'] * $row['retailprice'];
                                                            ?>
                                                            <td><?php echo number_format($total,2); ?></td>
                                                        </tr>
                                                        <?php } ?>

                    </tr>
                </tbody>
            </table>

    <!-- End of Page SALESTABLE.PHP -->



    <!--SALES_COUNT.PHP -->
    <?php require_once("../includes/db_connection.php"); ?>

                           <?php    
                               $count_client= mysqli_query($connection, "SELECT * FROM saleslog");
                               $count =  mysqli_num_rows($count_client);
                           ?>

                            <?php   
                                $totalsales= mysqli_query($connection, "SELECT SUM(total) AS totalpritems FROM saleslog");
                                while($totalperitems = mysqli_fetch_array($totalsales)){
                                $total_sales = $totalperitems['totalpritems'];
                                }
                           ?>


        <table class='table' style="border-style: dotted" id="sales_countid">
          <tr class='' style="border-style: dotted">
            <td width="50" >Total Items: </td>
            <td width="50"align="right"><?php echo $count; ?></td>
            <td width="50" >Total: </td>
            <td width="50"align="right" >P <?php echo number_format($total_sales,2); ?></td>
          </tr>
          <tr class='' style="border-style: dotted">
            <td width="50">Discount: </td>
            <td width="50"align="right">0.00 </td>
            <td width="50">Tax: </td>
            <td width="50"align="right">0.00 </td>
          </tr>
          <tr style="border-style: dotted">
            <td width>Total Payable: </td>
            <td align="right">P <?php echo  number_format($total_sales,2); ?></td>
            <td></td>
            <td></td>
          </tr>
        </table>
    <!--End of Page SALES_COUNT.PHP --> 


琉球
卡特巴洛根市

var表=$(“#salestableid”); var refresh=function(){ load(“salestable.php”,function()){ 设置超时(刷新,1); }); }; 刷新(); var表1=$(“#销售额_countid”); var refresh1=函数(){ load(“sales_count.php”,function()){ 设置超时(刷新1,1); }); }; 刷新1(); 取消 持有 付款

谢谢你,祝你今天愉快!

行动 产品 量 价格 全部的       项目总数: 总数: P 折扣: 0 税款: 0 应付总额: P
表1的刷新代码中,您可以改为刷新

table1.load(…)
而不是下面代码中的
table.load(…)

var table1 = $("#sales_countid");
var refresh1 = function() {
    table.load("sales_count.php", function() {
    setTimeout(refresh1, 1); 
    });
};