。。。一些相关的文件,貌似不能传递css值过去,所以必须要在news.html中写上。在主体部分
<script>
function viewpage(p){
if(window.XMLHttpRequest){
var xmlReq = new XMLHttpRequest();
} else if(window.ActiveXObject) {
var xmlReq = new ActiveXObject('Microsoft.XMLHTTP');
}
var formData = "page="+p;
xmlReq.onreadystatechange = function(){
if(xmlReq.readyState == 4){
document.getElementById('content2').innerHTML = xmlReq.responseText;
}
}
xmlReq.open("post", "news_main_ajaxpage2.php", true);
xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlReq.send(formData);
return false;
}
</script>
<body onLoad="viewpage(1)">
<div id="content2"></div>
news_main_ajaxpage2.php文件
<table width="786" border="0" cellspacing="0" cellpadding="5" height="27" background="../images/lanmu_top_2.jpg">
<tr>
<td>News</td><td align="right"></td>
</tr></table>
<?php
$pagesize=20;
require('../Connections/lr.php');
mysql_select_db($database_lr, $lr);
$rsbig=mysql_query("select * from news");
$myrowbig = mysql_fetch_array($rsbig);
$classid_big=$myrowbig['id'];
$bigclassname_big=$myrowbig['classname'];
//echo $_POST['page'];
mysql_select_db($database_lr, $lr);
$result = mysql_query("Select count(DISTINCT id) FROM news where yuyan=0");
$myrow = mysql_fetch_array($result);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
if (isset($_POST['page'])){
$page=intval($_POST['page']);
}
else{
//设置为第一页
$page=1;
}
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
//计算记录偏移量
$offset=$pagesize*($page - 1);
//读取指定记录数
$result=mysql_query("select * from news where yuyan=0 GROUP BY `id` order by id desc limit $offset,$pagesize");
$num = @mysql_num_rows($result);
while ($row = @mysql_fetch_array($result,MYSQL_NUM)) {
$id[]=$row[0];
$title[]=$row[1];
$date[]=$row[3];
//$countpeople[] = $row[1];
}
echo "<TABLE style=\"MARGIN-BOTTOM: 20px\" cellSpacing=0 cellPadding=0 width=786 border=0 align=center class='tableborder3'>\n";
echo "<TBODY>\n";
for($a=0;$a<$num;$a++)
{
echo "<TR>\n";
echo "<TD style=\"PADDING-TOP: 5px\" align=left><a href='../php2html/news_details.php?id=".$id[$a]."' target=_blank title='".$title[$a]."' class='news_toptitle_link' style='line-height:1.4em'>·".$title[$a]."</a></TD>";
echo "<Td align='right' width='180'>(".$date[$a].")</td>";
echo "</TR>";
}
echo "</TR></TBODY></TABLE>\n";
echo "<TABLE style=\"MARGIN-TOP: 30px\" cellSpacing=0 cellPadding=0 width=\"100%\"";
echo "border=0>";
echo "<TBODY><TR><TD colSpan=3 height=20>";
echo "<DIV align=center class='article'>";
echo "<P align=left><FONT color=red>".$page."/</FONT>".$pages." | Total:".$numrows."| ";
if ($page==1) echo "<a>First</a> | ";
if ($page>1) echo "<a onclick=\"viewpage(".$first.")\" href='#' class='article'>First</a> | ";
if ($page==1) echo "<a>Prev</a> | ";
if ($page>1) echo "<a onclick=\"viewpage(".$prev.")\" href='#' class='article'>Prev</a> | ";
if ($page<$pages) echo "<a onclick=\"viewpage(".$next.")\" href='#' class='article'>Next</a> | ";
if ($page==$pages) echo "<a>Next</a> | ";
if ($page<$pages) echo "<a onclick=\"viewpage(".$last.")\" href='#' class='article'>Last</a>";
if ($page==$pages) echo "<a>Last</a> | ";
echo " <INPUT maxLength=3 size=1 value=1 name=goto_page> <INPUT hideFocus onclick=\"viewpage(document.all.goto_page.value)\" type=button value=Go name=cmd_goto>";
echo "</P></DIV></TD></TR></TBODY></TABLE>";
?>
<script>
function viewpage(p){
if(window.XMLHttpRequest){
var xmlReq = new XMLHttpRequest();
} else if(window.ActiveXObject) {
var xmlReq = new ActiveXObject('Microsoft.XMLHTTP');
}
var formData = "page="+p;
xmlReq.onreadystatechange = function(){
if(xmlReq.readyState == 4){
document.getElementById('content2').innerHTML = xmlReq.responseText;
}
}
xmlReq.open("post", "news_main_ajaxpage2.php", true);
xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlReq.send(formData);
return false;
}
</script>
<body onLoad="viewpage(1)">
<div id="content2"></div>
news_main_ajaxpage2.php文件
<table width="786" border="0" cellspacing="0" cellpadding="5" height="27" background="../images/lanmu_top_2.jpg">
<tr>
<td>News</td><td align="right"></td>
</tr></table>
<?php
$pagesize=20;
require('../Connections/lr.php');
mysql_select_db($database_lr, $lr);
$rsbig=mysql_query("select * from news");
$myrowbig = mysql_fetch_array($rsbig);
$classid_big=$myrowbig['id'];
$bigclassname_big=$myrowbig['classname'];
//echo $_POST['page'];
mysql_select_db($database_lr, $lr);
$result = mysql_query("Select count(DISTINCT id) FROM news where yuyan=0");
$myrow = mysql_fetch_array($result);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
$pages++;
if (isset($_POST['page'])){
$page=intval($_POST['page']);
}
else{
//设置为第一页
$page=1;
}
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
//计算记录偏移量
$offset=$pagesize*($page - 1);
//读取指定记录数
$result=mysql_query("select * from news where yuyan=0 GROUP BY `id` order by id desc limit $offset,$pagesize");
$num = @mysql_num_rows($result);
while ($row = @mysql_fetch_array($result,MYSQL_NUM)) {
$id[]=$row[0];
$title[]=$row[1];
$date[]=$row[3];
//$countpeople[] = $row[1];
}
echo "<TABLE style=\"MARGIN-BOTTOM: 20px\" cellSpacing=0 cellPadding=0 width=786 border=0 align=center class='tableborder3'>\n";
echo "<TBODY>\n";
for($a=0;$a<$num;$a++)
{
echo "<TR>\n";
echo "<TD style=\"PADDING-TOP: 5px\" align=left><a href='../php2html/news_details.php?id=".$id[$a]."' target=_blank title='".$title[$a]."' class='news_toptitle_link' style='line-height:1.4em'>·".$title[$a]."</a></TD>";
echo "<Td align='right' width='180'>(".$date[$a].")</td>";
echo "</TR>";
}
echo "</TR></TBODY></TABLE>\n";
echo "<TABLE style=\"MARGIN-TOP: 30px\" cellSpacing=0 cellPadding=0 width=\"100%\"";
echo "border=0>";
echo "<TBODY><TR><TD colSpan=3 height=20>";
echo "<DIV align=center class='article'>";
echo "<P align=left><FONT color=red>".$page."/</FONT>".$pages." | Total:".$numrows."| ";
if ($page==1) echo "<a>First</a> | ";
if ($page>1) echo "<a onclick=\"viewpage(".$first.")\" href='#' class='article'>First</a> | ";
if ($page==1) echo "<a>Prev</a> | ";
if ($page>1) echo "<a onclick=\"viewpage(".$prev.")\" href='#' class='article'>Prev</a> | ";
if ($page<$pages) echo "<a onclick=\"viewpage(".$next.")\" href='#' class='article'>Next</a> | ";
if ($page==$pages) echo "<a>Next</a> | ";
if ($page<$pages) echo "<a onclick=\"viewpage(".$last.")\" href='#' class='article'>Last</a>";
if ($page==$pages) echo "<a>Last</a> | ";
echo " <INPUT maxLength=3 size=1 value=1 name=goto_page> <INPUT hideFocus onclick=\"viewpage(document.all.goto_page.value)\" type=button value=Go name=cmd_goto>";
echo "</P></DIV></TD></TR></TBODY></TABLE>";
?>