Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Refreshing a page with PHP

Posted by FloppyShoe (FloppyShoe), 2 March 2004
Hi everyone.  I am a relative newbiw to the world of PHP and programming in general.

I am writing a page that shows the date (and sometimes the time) on a page and my question is this :
Is there a way I can get the page to refresh itself, say every hour or so, so that if someone leaves the page open over-night, it will display the current date when they come back to the computer the following day rather than still displaying the date of the previous day.

I hope that makes sense and more importantly that someone will be able to help!!

Many thanks in advance,

FloppyShoe.

Posted by Chris_Isaac (Chris Isaac), 2 March 2004
hi

if you use the following at the top of the script it will force the browser to reload the page rather than use a cached copy:

Code:
header("Cache-Control:no-cache");




Posted by admin (Graham Ellis), 2 March 2004
I've put up a demo page at http://www.wellho.net/demo/clockpage.php4.   The source code of the page is:

Code:
<html>
<head>
<title>This is a clock page</title>
<<meta http-equiv="Refresh" content="60; URL=clockpage.php4">
</head>
<body>
<h1>This clock page refreshes every minute</h1>
It is now <?php print(date("H:i o\\n l, j F Y")) ?>
<hr>
Graham Ellis, <?php print (date ("Y")); ?>
</body>
</html>


Our server is in West Coast USA, so the report is Pacific time; you can vary that and should do so to suit the timezone of most of your users.

Chris's header shouldn't be necessary on a PHP page if the server is properly set up (but it would do no harm).  On an HTML page that you change frequently, it could be a good addition.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho