View Single Post
Old 09-29-2012, 04:12 PM   PM User | #3
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,399
Thanks: 18
Thanked 352 Times in 351 Posts
sunfighter is on a distinguished road
You do not need ajax for this. here is a method using php.

Code:
<?php
$do = 'yes';
$ann = '';
$file = @fopen("announcement.txt","r") or exit("announcement file does not exist!");
while(!feof($file))
  {
  $ann .= fgets($file);
  if($ann != '') $ann = $ann.'<br />';
  }
if($ann == '')
	$do = 'no';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>New document</title>
<style type="text/css">
#announcement{
	width: 300px;
	height: 100px;
	border: black solid 1px;
}
</style>
</head>
<body>
<?php
$mystring = <<<EOT
<div id="announcement">
$ann
</div>
EOT;
if($do == 'yes') echo $mystring;
?>
Give me an announcement
</body>
</html>
The text file "announcement.txt" is your announcement and looks like this:
Code:
Now is the time
for all good men
to come to the aid
of their country
Test this with the given text file. Then empty the text file of everything and lastly test it by deleting the file altogether.

If you like this approach and want further explanation of the code just LMK.
sunfighter is offline   Reply With Quote
Users who have thanked sunfighter for this post:
Hydrian (09-30-2012)