社区源代码(php&mysql)之四
//以下为bbstxt.php文件
<?
  
include "../inc/sql.inc.php";
  include 
"../inc/header.inc";

  switch(
$bbstitle){
  case
"1"$bbs_title="【HTML】";break;
  case
"2"$bbs_title="【PHP】";break;
  case
"3"$bbs_title="【JSP】";break;
  case
"4"$bbs_title="【CSS】";break;
  case
"5"$bbs_title="【SCRIPT】";break;
  case
"6"$bbs_title="【LINUX】";break;
  }

  if(!isset(
$show)) $show=0;                  //判断是否点击下一页

      
$sql="select * from bbs where blockid='$bbstitle' order by writetime DESC";
      
$result=mysql_query($sql);
      
$total=mysql_num_rows($result);
      
      
    if(
$total>0){
      for(
$i=0;$i<$total;$i++){
            
$row=mysql_fetch_array($result);

            
$mood[$i]=$row[mood];
            
$read_value[$i]=$row[read_value];
            
$title[$i]=$row[title];
            
$writer[$i]=$row[writer];
            
$writetime[$i]=$row[writetime];
            
$size[$i]=$row[size];
            
$bbsid[$i]=$row[bbsid];

            if(
$size[$i]>50){
                
$temp=explode("n",$row[content]);
                
$content[$i]=$temp[0];
            }

            else 
$content[$i]=$row[content];
      }
    }

         
$page=ceil($total/6);
         
$start=$show*6;
         
$end=$start+6;
         if(
$end>$total$end=$total;
         
$cun_page=$show+1;
         
$prv=$show;
         
$next=$page-1;
             

  
  function 
printlist(){                //输出表格
        
    
global $start,$end,$show,$mood,$read_value,$title,$content,     $writer,$writetime,$bbsid,$total,$id;

          for(
$i=$start;$i<$end;$i++){
     echo 
" <tr bgcolor=00ffff>n";
     echo 
"<td valign=center align=center height=29>";
     echo 
"<img src=../image/mood".$mood[$i].".gif width=15 height=15></img></td>n";
     echo 
"<td valign=center align=center>";
     echo 
"".$read_value[$i]."</td>n";
     echo 
"<td valign=center colspan=2>";
     echo 
"<a href=article.php?id=$id&bbsid=$bbsid[$i] target=_self>".$title[$i]."</a></td>n";
     echo 
"<td valign=center colspan=3>";
     echo 
"<a href=article.php?id=$id&bbsid=$bbsid[$i] target=_self>".$content[$i]."</a></td>n";
     echo 
"<td valign=center align=center colspan=2>";
     echo 
"<a href=look.php?userid=$writer[$i] target=_self>".$writer[$i]."</a></td>n";
     echo 
"<td valign=center align=center colspan=2>";
     echo 
"".date("m.d H:i",$writetime[$i])."</td>n";
     echo 
"</tr>n";
          }

    
$show++;
  }

  function 
printnone(){
      echo 
" <tr bgcolor=00ffff>n";
      echo 
"<td valign=center align=center height=29 colspan=12>";
      echo 
"目前还没有记录!^O^</td></tr>";
  }


             
?>
<html>
<head>
<title>BBS</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../css/internal.css" rel=stylesheet>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="632" border="0" cellpadding="0" cellspacing="1">
  <tr> 
    <td valign="center" height="29" colspan="3" >版面:<font color="ff0000"><?echo $bbs_title;?></font></td>
    <td valign="center" colspan="2">斑竹:<font color="ff0000">尹云飞 </font></td>
    <td valign="center" colspan="3">本栏目共有<font color="ff0000">【<?echo $total;?>】</font>篇文章</td>
    <td valign="center" colspan="2"><a href="writing.php?id=<?echo $id;?>&bbstitle=<?echo $bbstitle;?>" target="_self">发表文章</a></td>
    <td width="75" valign="center"><a href="writing.php?bbstitle=<?echo $bbstitle?>" target="_self">精华区</a></td>
  </tr>
  <tr bgcolor="#00ccff"> 
    <td width="25" height="29" valign="center" align="center"><font color="#ffffff">图象</font></td>
    <td width="27" valign="center" align="center"><font color="#ffffff">人气</font></td>
    <td valign="center" colspan="2" align="center"><font color="#ffffff">文章标题 
      </font></td>
    <td valign="center" align="center" colspan="3"><font color="#ffffff">文章内容</font></td>
    <td valign="center" colspan="2" align="center"><font color="#ffffff">作者</font></td>
    <td valign="center" colspan="2" align="center"><font color="#ffffff">时间 </font></td>
  </tr>
  <? if($total>0printlist(); else printnone();?>
  <tr bgcolor="#00ccff"> 
    <td height="29" colspan="4" valign="center" align="center">&nbsp; </td>
    <td valign="center" colspan="2" align="center">&nbsp;<a href=# onclick=JavaScript:history.back() target="_self"><?echo ($prv>0) ? "<<前一页":"";?></a></td>
    <td width="127" valign="center" align="center">&nbsp;<a href="bbstxt.php?id=<?echo $id?>&bbstitle=<?echo $bbstitle?>&show=<?echo $show;?>" target="_self"><?echo ($next>0) ? "后一页>>":""?></a></td>
    <td valign="center" align="center" colspan="2"> 共有<?echo $page?>页 </td>
    <td valign="center" align="center" colspan="2"> 第<?echo $cun_page?>/10页 </td>
  </tr>
  <tr> 
    <td height="1"></td>
    <td></td>
    <td width="50"></td>
    <td width="101"></td>
    <td width="45"></td>
    <td width="69"></td>
    <td></td>
    <td width="29"></td>
    <td width="63"></td>
    <td width="12"></td>
    <td></td>
  </tr>
</table>
<BR>
<?
include "../inc/copyright.inc";
?>
</body>
</html>