<?
	// 获取当前页数并设定每页记录条数	
	$p=floor(trim($p));
	$p=$p<=0?1:$p;
	$q=floor(trim($q));
	$q=$q<=0?10:$q;

	// 设置记录显示条件
	$condition=" status>0 ";

	// 获取总记录条数
	$sql="select count(id) from ".TBL_BULLETIN." where ".$condition." order by top desc , dt desc ";
	$totals=mysql_fetch_array(mysql_query($sql));
	$total=$totals[0];

	// 获取当前页记录集
	$sql="select * from ".TBL_BULLETIN." where ".$condition." order by top desc , dt desc limit ".(($p-1)*$q).",$q ";
	$i=0;
	$result=mysql_query($sql);
	while($row=mysql_fetch_array($result)){
		$lists[$i]=$row;
		$i++;
	}

	if(count($lists)>0){
		foreach($lists as $l){
			$bgcolor=$bgcolor=="#F9F9F9"?"#FFFFFF":"#F9F9F9";
			$ftcolor=$l["commend"]==1?"#FF0000":"#000000";
			$str=$l["top"]==1?" <sup><font style='color:#CC0000;font-size:11px;font-family:\"Comic Sans MS\";'>TOP</font></sup>":"";
			echo "<div style='width:100%;padding:2px;background:$bgcolor;'>";
			echo "	<span style='width:80%;color:$ftcolor;cursor:hand;' onclick=window.open('bulletin_show.php?id=".$l["id"]."','bulletin','width=400,height=300,left='+(screen.width-400)/2+',top='+(screen.height-300)/2+',scrollbars=1')>·".$l["title"].$str."</span>";
			echo "	<span>[ ".$l["dt"]." ]</span>";
			echo "</div>";
		}
	}
	
	echo "<hr style='width:90%;height:1px;color:#EEEEEE;text-align:center;'>";

	show_page($total);
?>