如何获取任何php mysql行的实时/实时计数?

时间:2017-10-10 21:16:10

标签: php html5 mysqli

我希望显示div中注册用户的总数。但希望它显示实时/实时计数。

我(目前)正在使用:

<?php 
$sql="SELECT * FROM QWERTY WHERE abc = '123' AND xyz = '789' ORDER BY id"; 
if ($result=mysqli_query($conn,$sql))  {  
   $rowcount=mysqli_num_rows($result);  
   printf("%d",$rowcount);  
   mysqli_free_result($result);  
} ?>

plz帮助我显示实时/实时计数

2 个答案:

答案 0 :(得分:0)

您可以使用一些jquery魔法从远程页面获取当前计数,然后将其放入DIV。

http://paste.liam.systems/view/QZVG63LUZ9

上面的脚本将每隔5秒从一个URL拉出并将其添加到div中。

答案 1 :(得分:0)

this is not what i was looking for but it worked ::

1.php


<html>
    <head>

    <script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
    <script>
    $(document).ready(function(){
        setInterval(function(){
            $("#count").load('2.php')
        }, 2000);
    });
    </script>
    </head>
    <body>
        <div id="count"></div>
    </body>
    </html>


2.php

<?php 
$sql="SELECT * FROM QWERTY WHERE abc = '123' AND xyz = '789' ORDER BY id"; 
if ($result=mysqli_query($conn,$sql))  {  
   $rowcount=mysqli_num_rows($result);  
   printf("%d",$rowcount);  
   mysqli_free_result($result);  
} ?>