重新加载
内的页面;与 $_GET

发布于 2024-12-05 14:42:53 字数 1904 浏览 1 评论 0原文

以下页面加载到我的index.php 中。我最初使用以下链接调用它:Import Mutuals

这部分工作得很好。我遇到的问题是底部的刷新代码: var auto_refresh = setInterval(function(){\$('#import').show('fast').load('fb_import_statuses.php?i=$ i').show('快');}, 1000);

我希望它最初加载记录 1,然后不断刷新,更新我的 SQL,直到达到记录 255。如果我使用 Meta Refresh 在 DIV 之外执行相同的代码,它会很好地执行序列,但使用此 JavaScript 刷新它将像这样的序列:

1, 2, 3, 2, 3, 4, 2, 3, 4, 5 等等...

我怎样才能将其序列为 1, 2, 3, 4, 5, 6, 7 等...

require 'batch_include.php';
require 'html_head.php';

if (isset($_GET['i'])){$i = $_GET["i"];} else {$i=0;}

$getcount = mysql_query("SELECT COUNT(id) AS get_count FROM people", $conn);
while ($row = mysql_fetch_array($getcount)){$get_count = "".$row{'get_count'}."";}

   $result = mysql_query("SELECT id FROM people LIMIT ".$i.",1", $conn);
   while ($row = mysql_fetch_array($result)){                                    
        $get_uid = addslashes("".$row{'id'}.""); 

    $me_friends = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT     status_id, message, source, time FROM status WHERE uid="'.$get_uid.'" LIMIT 5'));
    foreach ($me_friends as $fkey=>$me_friends){
        $get_status_id = $me_friends['status_id']; 
        $get_message = addslashes($me_friends['message']); 
        $get_source = $me_friends['source']; 
        $get_timestamp = $me_friends['time']; 

    $insert = mysql_query("INSERT INTO statuses (id, message, source, timestamp, uid)      VALUES ('$get_status_id', '$get_message', '$get_source', '$get_timestamp', '$get_uid')",     $conn);        
    }  
}             
$i = $i + 1;

if ($i<=$get_count){
echo "$i";
echo "<script>var auto_refresh = setInterval(function(){\$('#import').show('fast').load('fb_import_statuses.php?i=$i').show('fast');}, 1000);    </script>";
}

else {    
    echo "Import complete:  ";
    echo "<img src='/images/check.png'>";

    } 

The following page loads inside of on my index.php. I initially call it using the following link: Import Mutuals

This part works dandy. The problem I'm having is with the refresh code at the bottom: var auto_refresh = setInterval(function(){\$('#import').show('fast').load('fb_import_statuses.php?i=$i').show('fast');}, 1000);

I want it to initially load with record 1 and then keep refreshing, updating my SQL until it reaches record 255. If I do this same code outside of a DIV using Meta Refresh it steps through the sequence fine, but using this JavaScript refresh it will sequence like this:

1, 2, 3, 2, 3, 4, 2, 3, 4, 5 etc...

How can I get it to sequence as 1, 2, 3, 4, 5, 6, 7 etc...

require 'batch_include.php';
require 'html_head.php';

if (isset($_GET['i'])){$i = $_GET["i"];} else {$i=0;}

$getcount = mysql_query("SELECT COUNT(id) AS get_count FROM people", $conn);
while ($row = mysql_fetch_array($getcount)){$get_count = "".$row{'get_count'}."";}

   $result = mysql_query("SELECT id FROM people LIMIT ".$i.",1", $conn);
   while ($row = mysql_fetch_array($result)){                                    
        $get_uid = addslashes("".$row{'id'}.""); 

    $me_friends = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT     status_id, message, source, time FROM status WHERE uid="'.$get_uid.'" LIMIT 5'));
    foreach ($me_friends as $fkey=>$me_friends){
        $get_status_id = $me_friends['status_id']; 
        $get_message = addslashes($me_friends['message']); 
        $get_source = $me_friends['source']; 
        $get_timestamp = $me_friends['time']; 

    $insert = mysql_query("INSERT INTO statuses (id, message, source, timestamp, uid)      VALUES ('$get_status_id', '$get_message', '$get_source', '$get_timestamp', '$get_uid')",     $conn);        
    }  
}             
$i = $i + 1;

if ($i<=$get_count){
echo "$i";
echo "<script>var auto_refresh = setInterval(function(){\$('#import').show('fast').load('fb_import_statuses.php?i=$i').show('fast');}, 1000);    </script>";
}

else {    
    echo "Import complete:  ";
    echo "<img src='/images/check.png'>";

    } 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

jJeQQOZ5 2024-12-12 14:42:53

问题是您添加了多个 setInterval 函数(每次加载页面时您都会回显另一个方法)。尝试将您的刷新方法放在 div 之外,或者让它调用一个包含负责从数据库检索信息的 php 代码的函数。

如果您不必每秒刷新页面,您可以使用一个 php 文件从数据库获取所有数据,并以某种形式返回(例如 json ) 。我认为这将是做到这一点的最好方法。

the problem is that you add multiple setInterval functions (everytime the page is loaded you echo another method). try putting your refreshing method out of the div or make it call a function that includes php code responsible for retrieving information from db.

if you don't have to refresh the page every second, you could get all the data from db with one php file and return it in some form (json for example). I think this would be the best way to do this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文