Hello,
I have the following "messages.php" that refreshes every 15 minutes. A separate script writes to the MYDB1 database based on user input. I need an AJAX based methosd to update the web page, as opposed to the refresh below.
thanks,
Arun
<HTML>
<HEAD>
<meta http-equiv="refresh" content="15">
</HEAD>
<body onload="scrollTo(0,9999);">
<TABLE>
<?php
$con = mysql_connect("localhost","test","testpasswd");
$table = messages;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(MYDB1);
$query = "SELECT * FROM $table";
$result = mysql_query($query);
$num = mysql_num_rows($result);
mysql_close();
if ($num > 50)
{
$i = $num - 50;
}
else
{
$i = 0;
}
while ($i < $num) {
$f1 = mysql_result($result,$i,"Username");
$f2 = mysql_result($result,$i,"Time");
$f3 = mysql_result($result,$i,"Message");
?>
<TR>
<TD width="25%" align="right"><span style="font-size:11;color:#D40606;"><b><?php echo $f1; ?>
<span style="font-size:11;color:lightgrey;"> [<?php echo $f2; ?>]:</b></span></TD>
<TD width="75%" align="left"><span style="font-size:11;color:black;"><b> <?php echo $f3; ?></b></span></TD>
</TR>
<?php
$i++;
}
?>
</TABLE>
</body>
</HTML>
I have the following "messages.php" that refreshes every 15 minutes. A separate script writes to the MYDB1 database based on user input. I need an AJAX based methosd to update the web page, as opposed to the refresh below.
thanks,
Arun
<HTML>
<HEAD>
<meta http-equiv="refresh" content="15">
</HEAD>
<body onload="scrollTo(0,9999);">
<TABLE>
<?php
$con = mysql_connect("localhost","test","testpasswd");
$table = messages;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(MYDB1);
$query = "SELECT * FROM $table";
$result = mysql_query($query);
$num = mysql_num_rows($result);
mysql_close();
if ($num > 50)
{
$i = $num - 50;
}
else
{
$i = 0;
}
while ($i < $num) {
$f1 = mysql_result($result,$i,"Username");
$f2 = mysql_result($result,$i,"Time");
$f3 = mysql_result($result,$i,"Message");
?>
<TR>
<TD width="25%" align="right"><span style="font-size:11;color:#D40606;"><b><?php echo $f1; ?>
<span style="font-size:11;color:lightgrey;"> [<?php echo $f2; ?>]:</b></span></TD>
<TD width="75%" align="left"><span style="font-size:11;color:black;"><b> <?php echo $f3; ?></b></span></TD>
</TR>
<?php
$i++;
}
?>
</TABLE>
</body>
</HTML>