Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 05-07-2007, 09:12 AM Javascript/PHP
mad_willsy's Avatar
Super Spam Talker

Latest Blog Post:
PC World Placement
Posts: 801
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
Trades: 0
How do i get javascript to include a text/php file and then reinclude it every 20 seconds to look for changes and update the changes on the page without refreshing?

I wan't this php code to be reprocessed every 20 seconds to get any new messages....

PHP Code:
<?php    
$sql 
"SELECT * FROM `shoutbox` ORDER BY `time` DESC LIMIT 20";
$result mysql_query($sql) or die(mysql_error());
while(
$row mysql_fetch_array($result)){
$username $row["username"];
$shout $row["shout"];
$time $row["time"];
$time ago2($time);
$shout wordwrap($shout,75,'');
$statsid mysql_query("SELECT `statsid` FROM `users_data` 
WHERE `username` = '
$username'"); 
$statsid mysql_fetch_array($statsid);
$statsid $statsid['statsid'];
print (
"<tr height='10'>");
print (
"<td align=left valign=top>$time</td>");
print (
"<td align=left valign=top><a href='http://www.soldierextreme.com/stats.php?id=$statsid'><b>$username</b></a></td>");
print (
"<td align=left><kbd>$shout</kbd></td>");
print (
"</tr>"); 
}
?>
__________________
Wont :P

Please login or register to view this content. Registration is FREE
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
 
Register now for full access!
Old 05-07-2007, 09:50 AM Re: Javascript/PHP
mad_willsy's Avatar
Super Spam Talker

Latest Blog Post:
PC World Placement
Posts: 801
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
Trades: 0
I've made it recall the date every 10 seconds, but now i need it to recall a php file every 10 seconds...


Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript">
function Update() {
var timeout = 0;
var nbj=document.getElementById('messages');
if(nbj==null){
return;
} 
nbj.innerHTML=  new Date();
timeout = setTimeout("Update()", 10000);
}
function Start() {
timeout = setTimeout("Update()", 50);
}
 
function Kill() {
   if(timeout) {
      clearTimeout(timeout);
      timeout = 0;
   }
}

//-->

</script>
</head>
<body onload="Start()" onunload="Kill()">
<table ><tr><td id="messages"></td></tr></table>
</html>
__________________
Wont :P

Please login or register to view this content. Registration is FREE
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
Old 05-08-2007, 04:47 AM Re: Javascript/PHP
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
You really ought to look at Ajax as this is exactly the type of things Ajax is perfect for.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Javascript/PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25666 seconds with 12 queries