使用setinterval()更基本的PHP代码 [英] Using setinterval() more basic for PHP code
问题描述
大家好,我有2个问题给你!
1)让我们做样品;在数据库中;
user_id user_x user_ y 存在。
我有一个abc.php文件,它获取数据库中的所有user_id并更新所有user_x user_y行。要执行此abc.php,我有一个oto.php,它有setInterval js.So oto.php每3运行一次abc.php秒和执行代码。
$(文件).ready(function(){
setInterval (function(){
$('#show2')。load('abc.php')
},3000);
});
哇我已经为一个请求提交了2个文件....我怎样才能让这种情况变得更简单?
2)所以我们更新了user_x和user_y,但现在我们必须每3秒获取一次这个数据。所以我再次创建一个名为hop.php的文件,我将此user_x user_y数据发送到php.It列出如user_x = 24 user_y = 59。然后我需要将这些数据作为实时显示给用户,同时这些数据正在增加。所以我创建了index.php并再次使用这个js。
$(文件).ready(function(){
setInterval(function(){
$('#show')。load('hop.php')
},3000);
});
并创建一个div#show并列出到screen.BUT我想在页面上列出不同的地方。我的意思是我需要单独获取user_x和user_y数据并再次更新它们3秒(因为oto.php在数据库中增加这些值,所以我需要显示这些值而不是reflesh)
我如何单独获得这些值,以便我可以将它们放在我想要的任何地方...
感谢您的帮助!
我尝试了什么:
好吧我不想拆分主题所以我写了上面的
Hello guys I have 2 question for you!
1) Lets make a sample; in database;
user_id user_x user_ y exist.
And I have a abc.php file which is get the all user_id in database and update all the user_x user_y rows.To execute this abc.php i have a oto.php and it has setInterval js.So oto.php runs abc.php every 3 seconds and execute the code.
$(document).ready(function() {
setInterval(function(){
$('#show2').load('abc.php')
},3000);
} );
Wow I already 2 file for one request....How can I make this situation more simple?
2) So we update the user_x and user_y but now we have to get this datas every 3 sec. So again I create a file called hop.php and I get this user_x user_y datas to php.It listed like user_x=24 user_y=59. Then i need to show this data to user as real time while these are increasing. So i created index.php and again use this js.
$(document).ready(function() {
setInterval(function(){
$('#show').load('hop.php')
},3000);
} );
and create a div#show and listed to screen.BUT i wanna list them different place on page.I mean i need to get user_x and user_y data separately and again update them 3 sec.(because oto.php increase these values in database so i need to show these value without reflesh)
How can i get these values separately so that i can put them everywhere i want...
Thanks for help!
What I have tried:
Well i dont wanna split the topic so i wrote the above
推荐答案
(document).ready(function(){
setInterval(function(){
(document).ready(function() {
setInterval(function(){
('#show2 ')。load('abc.php')
},3000);
});
哇我已经为一个请求提交了2个文件....我怎样才能让这种情况变得更简单? />
2)因此我们更新了user_x和user_y,但现在我们必须每3秒获取一次这个数据。所以我再次创建一个名为hop.php的文件,我将此user_x user_y数据发送到php.It列出如user_x = 24 user_y = 59。然后我需要将这些数据作为实时显示给用户,同时这些数据正在增加。所以我创建了index.php并再次使用这个js。
('#show2').load('abc.php')
},3000);
} );
Wow I already 2 file for one request....How can I make this situation more simple?
2) So we update the user_x and user_y but now we have to get this datas every 3 sec. So again I create a file called hop.php and I get this user_x user_y datas to php.It listed like user_x=24 user_y=59. Then i need to show this data to user as real time while these are increasing. So i created index.php and again use this js.
(document).ready(function (){
setInterval(function(){
(document).ready(function() {
setInterval(function(){
这篇关于使用setinterval()更基本的PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!