Saturday, January 23, 2010

Auto Refresh / Reload Web Page

To make the page reload or refresh itself, we have to use the following code inside the head tag.
<meta http-equiv="refresh" content="5" >
The attribute http-equiv="refresh" calls for refresh of the page.

The attribute content="5" sets the time for refresh.

The time after which the page has to reload is set using the content attribute.
Say if you want the page to refresh after 10 seconds interval, set content value to 10.

We would recommend the time of refresh [reloading interval] be above 5 seconds. This is because you have to consider the page loading time.

Example , online.php with auto refresh for 60 seconds :

<?php // ---- online.php ----
session_start();
include "global.inc.php";
?>
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<meta http-equiv="refresh" content="60" >
<TITLE>Online User Webmail BATAN</TITLE>
<META NAME="GENERATOR" CONTENT="gEdit 2.20.3 (Linux)">
<META NAME="CREATED" CONTENT="20080304;11545200">
<META NAME="CHANGEDBY" CONTENT="Muh. Sirojul Munir">
<META NAME="CHANGED" CONTENT="20080304;12344100">
<META NAME=author CONTENT="Muh. Sirojul Munir">
<META NAME="description" CONTENT="online user webmail">
<META NAME="keywords" CONTENT="online, webmail, batan">
<link rel="Shortcut Icon" href="/favicon.ico" />
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
</HEAD>
<BODY>
<?php
$pageId=$_GET['pageId'];
$sqlSelect=$_POST['sqlSelect'];
$submitBtn=$_POST['submitBtn'];
$typeSelect=$_POST['typeSelect'];
$search=$_POST['search'];
$waktu=date("H:i:s d-m-Y");
$sqlLimit="select distinct ou_user from onlineusers order by ou_user asc";
$dbconnect=mysql_query($sqlLimit);
$rec_num=mysql_num_rows($dbconnect);
//echo "$sqlRekRows";
echo "
<br>
<font color=#0aa1bc face=verdana size=5><b>ONLINE USER WEBMAIL BATAN</b></font>
<br><br>";
echo "
<br>
Waktu saat ini: $waktu
<br><br>
<table width=25% class=ntn>
<tr>
<th align=left>Username</th>
</tr>
";
for($RekRows=0;$RekRows<$rec_num;$RekRows++){
$getval=mysql_fetch_array($dbconnect);
$_ou_timestamp=$getval[ou_timestamp];
$_ou_user=$getval[ou_user];
$_ou_right_main=$getval[ou_right_main];
$id=$getval[id];
echo "
<tr bgcolor=".strip2($RekRows).">
<td align=left><font face=verdana size=3>$_ou_user</font></td>
</tr>";
}
echo "</table>";
echo "Total user: ";
echo "$rec_num";
?>
</BODY>
</HTML>


Sumber :
http://www.hscripts.com/

No comments:

Post a Comment