2016-11-12 207 views
1

我想在每次使用时更新我选择的元素中的显示数据editqtycan.php在一个弹出窗口中。我正在创建一个条码系统。请帮助我如何在不刷新页面的情况下更新它。自动刷新显示表无需重新加载页面

<?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> 

回答

0

是的。可以仅刷新页面上的选定元素。您可以通过使用AJAX通信的JavaScript代码来完成此操作。您可以使用jQuery库,合理地利用它为您的代码很快做到这一点。阅读jQuery的文档$就功能:http://api.jquery.com/jquery.ajax/

或者,也许你并不需要与服务器的PHP脚本进行通信。也许你可以通过只在(浏览器)使用JS在客户端达到你的目的。

而最后一件事。尽量避免混合使用HTML和PHP。我的意思是echo "<div></div>“'。您可以关闭PHP标签并编写干净的HTML代码。它看起来更好,效率更高。

+0

谢谢你的建议,我会记住这一点。 – EHEM

相关问题