<?php header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
?>
<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", "show_main2.php", true);
xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlReq.send(formData);
return false;
}
</script>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<div id="content2">
<?php
$pagesize=5;
//
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
require "conn.php";
mysql_query("set names utf8;");
//if ($lr) {
//echo "非常好,MYSQL连接成功了!";
//} else {
//echo "不好意思,失败了!";
//}
mysql_select_db($database_lr, $lr);
//
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 shoutbox");
$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 shoutbox 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];
$content[]=$row[1];
$date[]=$row[2];
//$countpeople[] = $row[1];
}
echo "<TABLE style=\"MARGIN-BOTTOM: 20px\" cellSpacing=0 cellPadding=3 width=100% border=0 align=center>\n";
echo "<TBODY>\n";
for($a=0;$a<$num;$a++)
{
echo "<TR>\n";
echo "<TD style=\"PADDING-TOP: 5px\" align=left><img src='images/date-bg.png' style='margin-bottom:-1px;'> ".$content[$a]."</TD>";
echo "<Td align='right' width='180'>(".$date[$a].")</td>";
echo "</TR>";
echo "<tr><Td height='1px' bgcolor='#cccccc' colspan='2'></td></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=right><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 "</P></DIV></TD></TR></TBODY></TABLE>";
?></div>