Reload a php include every 5 minutes

If coding is more your thing then the Website Development & Scripting forums are for you. Share server-side scripting and database integration tips, tricks and problems here.
Post Reply
wright
Newbie
Posts: 6
Joined: Sun Oct 01, 2017 6:41 pm

Sun Oct 01, 2017 6:45 pm

I'm programming with php, and I do not know of Jquery. 

Inside my page I make an include ('show.php'); 

I need this to be reload every 5 minutes without updating the page. 

Incorporate the same Jquery in this way

Code: Select all

<script src = "jquery-3.2.1.min.js" type = "text / javascript"> </ script>
and then in the body I call the file this way

Code: Select all

<div class = "example"> 
 <ul class = "nav"> 
<? php include ('show.php'); 
 </ ul> 
</ div>
Thanks in advance.


User avatar
edwin
Junior Member
Posts: 18
Joined: Thu Sep 28, 2017 6:17 pm

Sun Oct 01, 2017 6:50 pm

the php is executed only once on the server and ready, after sending the client the execution is finished, there is nothing else you can do with it ...

for what you want there are 2 possibilities

one is iframes another is ajax
-iframe is a web page inside another, like a window, there you can load instead of include, the file of this, and you can add it as a header to be updated every 5 min

-ajax is a cross-technique where you call php with a jscript
wright
Newbie
Posts: 6
Joined: Sun Oct 01, 2017 6:41 pm

Sun Oct 01, 2017 6:52 pm

edwin wrote: the php is executed only once on the server and ready, after sending the client the execution is finished, there is nothing else you can do with it ...

for what you want there are 2 possibilities

one is iframes another is ajax
-iframe is a web page inside another, like a window, there you can load instead of include, the file of this, and you can add it as a header to be updated every 5 min

-ajax is a cross-technique where you call php with a jscript
That's what I was finding out, but I did not get the JQuery code to do it, over I change the way to do the load in 3.1
User avatar
edwin
Junior Member
Posts: 18
Joined: Thu Sep 28, 2017 6:17 pm

Sun Oct 01, 2017 6:55 pm

Code:

Code: Select all

 < div  id = "receiver" > here the data will be updated < / div > 
Code:

Code: Select all

$ (  "#receptor"  ) . load (  "pageload.php"  ) ;
or do it with a timeout or similar
wright
Newbie
Posts: 6
Joined: Sun Oct 01, 2017 6:41 pm

Sun Oct 01, 2017 6:58 pm

edwin wrote: Code:

Code: Select all

 < div  id = "receiver" > here the data will be updated < / div > 
Code:

Code: Select all

$ (  "#receptor"  ) . load (  "pageload.php"  ) ;
or do it with a timeout or similar
It worked for me, now I should get the timeout.
User avatar
edwin
Junior Member
Posts: 18
Joined: Thu Sep 28, 2017 6:17 pm

Sun Oct 01, 2017 7:00 pm

Code:

Code: Select all

 setInterval ( function ( ) {  // call as an anonymous function to summarize
  $ (  "#receptor"  ) . load (  "pageload.php"  ) ;
} ,  1000 * 60 * 5 ) ;  // 1000 milliseconds per second, 60 seconds per minute, 5 minutes
this should suffice
wright
Newbie
Posts: 6
Joined: Sun Oct 01, 2017 6:41 pm

Sun Oct 01, 2017 7:02 pm

edwin wrote: Code:

Code: Select all

 setInterval ( function ( ) {  // call as an anonymous function to summarize
  $ (  "#receptor"  ) . load (  "pageload.php"  ) ;
} ,  1000 * 60 * 5 ) ;  // 1000 milliseconds per second, 60 seconds per minute, 5 minutes
this should suffice
Thank you very much, it works perfect.
User avatar
Helsa
Junior Member
Posts: 17
Joined: Wed Sep 17, 2014 9:23 am

Sun Oct 01, 2017 7:08 pm

Usually that is a bad practice, what you should do is go to search the data with ajax and modify the data dynamically on the website from javascript or if you want to deploy information in real time you must use websockets.

Code: Select all

 http://www.phpbuilder.com/articles/application-architecture/optimization/creating-real-time-applications-with-php-and-websockets.html
wright
Newbie
Posts: 6
Joined: Sun Oct 01, 2017 6:41 pm

Sun Oct 01, 2017 7:11 pm

Helsa wrote: Usually that is a bad practice, what you should do is go to search the data with ajax and modify the data dynamically on the website from javascript or if you want to deploy information in real time you must use websockets.

Code: Select all

 http://www.phpbuilder.com/articles/application-architecture/optimization/creating-real-time-applications-with-php-and-websockets.html
Friend, Thank you very much. I solved it with the previous help, but I'll read about what you recommended. 

As a comment I add that what I charge is a table made with php and mysql, and I still do not know ajax but I will start to study it.
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests