简体   繁体   English

自动刷新显示表而无需重新加载页面

[英]auto refresh display table without reloading page

i would like to update my display data in a selected element every time i'm using editqtycan.php in a popup window. 每当我在弹出窗口中使用editqtycan.php时 ,我想更新所选元素中的显示数据。 i'm creating a barcode system. 我正在创建一个条形码系统。 Please help me how can i update it without refreshing the page time by time. 请帮助我如何在不刷新页面的情况下更新它。

<?php

$sql="SELECT allinvty3.*, barcode.* , pd_stock_transfer.*, barcode.qty  as codeqty, barcode.id as barcodeid  from pd_stock_transfer 
            LEFT JOIN barcode on pd_stock_transfer.in_code = barcode.itemcode  

            INNER JOIN allinvty3 on pd_stock_transfer.in_code = allinvty3.in_code 
            where pd_stock_transfer.refnumber='$temp' and barcode.refnumber='$temp' and barcode.receivestatus='INCLUDED' group by  barcode.itemcode ORDER BY allinvty3.ecr_desc ASC ";
            $result = $conn->query($sql); 

 echo"<div style='height:450px; overflow-y: scroll;'>";
 echo "<table class='table table-bordered table-hover table-condensed '>";
            echo"<tr class='info'><th>MODEL</th><th>ITEM CODE</th><th>ACTUAL REC.</th><th>REQUEST QTY.</th><th>DIFF.</th>
            </tr>";
             echo"<font size='5'><p class='text-primary'>ACTUAL</p></font>";

            while($row = $result->fetch_assoc()){
            $receivestatus =$row['receivestatus'];
            $icount = $row['codeqty'];
            $qty = $row['qty'];
            $total1 = $row['codeqty'] - $qty;

 //I want this division an auto update every time I want to edit the ***qty row***.
                echo"<tr>";
                    echo "<td align= center>".$row['ecr_desc']."</td>";
                    echo "<td align= center>".$row['itemcode']."</td>";
                    echo "<td align=center>".$row['codeqty']."</td>";
                    echo "<td align=center>".$row['qty']."</td>";
                    if ($icount >  $row['qty']){
                    echo"
                    <td bgcolor='#FF0000' align='center'>";}
                    else if ($icount <  $row['qty']){
                    echo"<td bgcolor=   '#006400' align='center'>";
                    }
                     else{
                    echo"
                    <td align='center'>";
                    }
                    {
                    echo " ".$total1."</td>";
                    }
        //this link is where I can edit the qty in a popup window. I don't want to use bodyonunload.           
         echo"<td><a href='#' onclick=PopupCenter1('editqtyscan.php?Tid=".$row['barcodeid']."','myPop2',400,400)>Edit Qty</a></td>";
                    }?>
                    </tr>
</table></div></div>

Yes. 是。 It is possible to refresh only selected element on page. 可以仅刷新页面上的选定元素。 You can do it by JavaScript code with AJAX communication. 您可以通过AJAX通信的JavaScript代码来完成。 You can use jQuery library to do this quickly by using it properly for your code. 您可以使用jQuery库通过正确使用它来代码来快速完成此操作。 Read jQuery documentation for $.ajax function: http://api.jquery.com/jquery.ajax/ 阅读$ .ajax函数的jQuery文档: http//api.jquery.com/jquery.ajax/

Or maybe you do not need to communicate with server PHP script. 或者您可能不需要与服务器PHP脚本进行通信。 Maybe you can achieve your purpose by only using JS on client side (in a browser). 也许你可以通过在客户端(在浏览器中)使用JS来实现你的目的。

And last thing. 最后一件事。 Try to avoid mixing HTML and PHP. 尽量避免混合使用HTML和PHP。 I mean echo "<div></div> "'. 我的意思是echo "<div></div> ”'。 You can close PHP tags and write clean HTML code. 您可以关闭PHP标记并编写干净的HTML代码。 It looks better and is more efficient. 它看起来更好,效率更高。

Well here is the answer ! 那么这就是答案! You need AJAX ! 你需要AJAX! Nothing new to learn ! 没什么好学的! It is just javascript code which communicate with server behind the scenes. 它只是在后台与服务器通信的javascript代码。 You don't need to reload ! 你不需要重装! BEST tutorial here -> http://www.w3schools.com/xml/ajax_intro.asp Happy coding ☺ 最佳教程 - > http://www.w3schools.com/xml/ajax_intro.asp快乐编码☺

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM