<?
ob_start();
include_once('mysql.php');
include_once('inc.php');
$id=$_GET['id'];
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>镇江消费网 - <?=$NewsClass[$id]?></title>
<link href="style.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="functions.js" type="text/JavaScript"></script>
</head><body leftmargin="0" topmargin="0">
<? include('top.php');?>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="150" height="279" valign="top"><table width="145" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#eaf4ff">
        <tr> 
          <td height="13"><img src="images/xfzn.gif" width="145" height="20"></td>
        </tr>
        <tr> 
          <td><table width="145" border="0" cellpadding="0" cellspacing="0" bgcolor="#0094f7">
              <tr> 
                <td><table width="143" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td valign="top" bgcolor="#eaf4ff">
                        <? include('tnews.php'); tnews($id);?>
                      </td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td height="13"><img src="images/down1.gif" width="145" height="10"></td>
        </tr>
      </table> 
      <table height=8 cellspacing=0 cellpadding=0 width=100% align=center border=0>
        <tbody>
          <tr> 
            <td></td>
          </tr>
        </tbody>
      </table>
      <table width="145" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#eaf4ff">
        <tr> 
          <td height="13"><img src="images/top.gif" width="145" height="20"></td>
        </tr>
        <tr> 
          <td><table width="145" border="0" cellpadding="0" cellspacing="0" bgcolor="#0094f7">
              <tr> 
                <td><table width="143" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr> 
                      <td valign="top" bgcolor="#eaf4ff">
                        <? include('tcompany.php');?>
                      </td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td height="13"><img src="images/down1.gif" width="145" height="10"></td>
        </tr>
      </table></td>
    <td width="4" valign="top"></td>    <td valign="top"><table width="100%" height="24" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td>&nbsp;<a href="index.php">首  页</a> - <?=$NewsClass[$id]?></td>
        </tr>
      </table>
      <TABLE align=center border=0 cellPadding=4 cellSpacing=6 width="100%">
          <TR> 
            <th width="70%" class=p9>标题</th>
            <th width="18%" class=p9>日期</th>
            <th width="12%" class=p9>点击次数</th>
          </TR>
<?
$npp=12;
$page=isset($_GET['page'])?$_GET['page']:1;
$first=($page-1)*$npp;
$sql="select * from news where `分类`=$id and `审核`=1 ";
$sqlc="select count(*) from news where `分类`=$id  and `审核`=1";
$sql.="order by `编号` desc limit $first, $npp";
$row=mysql_fetch_row(mysql_query($sqlc));
$pages=ceil($row[0]/$npp);

$result=mysql_query($sql); $n=0; $c1="#D9F0FF"; $c2="#ffffff";
while($row=mysql_fetch_array($result)){
?>
          <TR bgcolor="<?=($n++ % 2)==0?$c1:$c2?>"> 
            <TD><a href="nshow.php?id=<?=$row[0]?>"><IMG border=0 height=12 src="images/icon_article.gif" width=16 valign="absmiddle"> <?=$row['标题']?></a></TD>
            <TD align="center"><?=substr($row['时间'],0,10)?></TD>
            <TD align="right"><?=$row['点击']?></TD>
          </TR>
<?
}
?>
      </TABLE>
      <table width="99%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td align="center">第 <?=$page?> 页 共 <?=$pages?> 页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?
$href="news.php?";
$d=floor(($page-1)/10);
$firsti=1+$d*10;
$lasti=10+$d*10;
$lasti=$lasti>$pages?$pages:$lasti;
if($page>10)
print "<a href=$href&page=".($firsti-1).">&lt;&lt;</a> ";
for($i=$firsti; $i<=$lasti; ++$i){
if($i==$page) print "<font color=#FF0000><b>$i</b></font> ";
else print "<a href=$href&page=$i>$i</a> ";
}
if($lasti<$pages)
print "<a href=$href&page=".($lasti+1).">&gt;&gt;</a>";
?></td>
        </tr>
      </table></td>
  </tr>
</table>
<? include('bottom.php');?>
</body>
</html>

解决方案 »

  1.   

    include "config.php";
      $link=mysql_connect($host,$user,$pass);
      mysql_select_db($db);
      $qh=mysql_query("SELECT COUNT(*) AS rcnt from $dbtable"); 
    $data=mysql_fetch_array($qh); 
    首先查一下,是否以上这段出错,如果是,那就是MYSQL或PHP没设置好
      

  2.   

    不是啊,zjtjs兄,是这种情况了,比如显示[1][2][3][4][5],可点[2][3]还是显示第一页的
      

  3.   

    if (empty($offset)) 

    $offset=0; 

    $result=mysql_query("select * from $dbtable  limit $offset, $list_num");
    好像该改成
    if (empty($offset)) 

    $list_num=0; 
    else
    $list_num=....

    $result=mysql_query("select * from $dbtable  limit $offset, $list_num");