<?php
$dbhost="localhost";
$dbuser="
$dbpass="
$dbname="
$table="news";
$link=@mysql_connect($dbhost,$dbuser,$dbpass);
if(!$link)
{
print"&newsText=".urlencode("could not connect to server!");
exit;
}
if(!@mysql_select_db($dbname))
{
print"&newsText=".urlencode("could not select $dbname database!");
exit;
}
?>
<?php
include'common.php';
$page=$_POST['page']*5;
$query="select * from news order by newsID limit $page,5";
$result=@mysql_query($query);
if($result&&@mysql_num_rows($result)>0)
{
$newsText="";
while($row=mysql_fetch_array($result))
{
$posted=strftime("%H:%M",$row['posted']);
$newsText.=stripslashes($row['bt']);
$newsText.='<br>';
$newsText.='<font size="10">';
$newsText.=$posted."by".$row['author'];
$newsText.='</font><br>';
$newsText.=stripslashes($row['body']);
$newsText.='<br><br>';
}
print "&newsText=".urlencode($newsText);
}
else
{
print "&newsText=".urlencode("No news items yet");
}
mysql_close($link);
?>
这就是php部分的代码,从而省略了updown.php这一段代码,本fetchnews.php代码修改了两个地方,第一个地方是把
System.useCodepage=true;
newsText="";
loadVariables("fetchnews.php?"+(Math.random()*1000000),this,"POST");//以POST形式使用fetchnews.php中的数据
stop();