一个模仿oso的php论坛程序源码(之三)_php实例

PHP中文网
Libérer: 2016-05-17 09:40:46
original
973 Les gens l'ont consulté

程序三:readforum.php 

<HTML>  
<HEAD>  
<TITLE> 论坛信息 </TITLE>  
<link rel="STYLESHEET" type="text/css" href="fp_zhangcg.css">  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
<meta name="Microsoft Theme" content="none">  
<meta name="Microsoft Border" content="none">  
<META NAME="Generator" CONTENT="EditPlus">  
<META NAME="Author" CONTENT="">  
<META NAME="Keywords" CONTENT="">  
<META NAME="Description" CONTENT="">  
</HEAD>  
<body bgcolor="#C0C0C0" background="backcolor.GIF">  
<?  
  include ("c:mydbheader.inc");  
?>  
<?php   
//完成功能:  
//echo $username;  
//echo $useremail;  
//echo $userhttp;  
//echo $forumtitle;  
//echo $fouumface;  
//echo $forumcontent;   
//echo $theme_id;  
echo &#39;g_username:&#39;.$GLOBALS["g_username"].&#39; is ok&#39;;  
$dbh = mysql_connect(&#39;localhost:3306&#39;,&#39;root&#39;,&#39;&#39;);  
mysql_select_db(&#39;test&#39;);   
if (empty($readflag)) {  
   $readflag = 0;  
}   
if ($readflag > 0) {  
   $theme_id = $readflag;  
}  
if (empty($theme_id)) {  
   $theme_id = 0;  
}   
//echo $username;  
//echo $useremail;  
//echo $userhttp;  
//echo $forumtitle;  
//echo $fouumface;  
//echo $forumcontent;   
if (($readflag == 0) and ($theme_id == 0)) {   //增加数据  
    if (empty($username)) {  
       print "错误,请核对数据";  
    }  
     $res=mysql_query("SELECT max(id) + 1 AS rid FROM fr_t_forumtitle",$dbh);    
    $row=mysql_fetch_array($res);  
    if (empty($row["rid"])) {  
       $theme_id = 1;    
    } else {  
      $theme_id = $row["rid"] + 1;    
    }  
    $tempstr = " insert into fr_t_forumtitle(id,state,readcount,replycount,title,";  
    $tempstr = $tempstr."createman,replytime) ";  
    $tempstr = $tempstr." values(".$theme_id.",&#39;0&#39;,0,-1,&#39;".$forumtitle."&#39;,&#39;".$username."&#39;,now());";  
    $res=mysql_query($tempstr,$dbh);  
}  
if ($readflag == 0 ) {  
    $forumcontent =  nl2br($forumcontent);  
    $tempstr = " insert into fr_t_forumcontent(id,content,replyman,replyemail,";  
    $tempstr = $tempstr."replyhttp,replytime,replyface)";  
    $tempstr = $tempstr." values(".$theme_id.",&#39;".$forumcontent."&#39;,&#39;".$username."&#39;,&#39;".  
        $useremail."&#39;,&#39;".$userhttp."&#39;,now(),".$forumface.");";  
    $res=mysql_query($tempstr,$dbh);  
    $tempstr = " update fr_t_forumtitle set readcount = readcount +1,replycount = replycount + 1,";  
    $tempstr = $tempstr."replytime = now(),replyman =&#39;".$username."&#39; where id=".$theme_id;   
    $res=mysql_query($tempstr,$dbh);  
} else {  
    $tempstr = " update fr_t_forumtitle set readcount = readcount +1 where id =".$theme_id;  
    $res=mysql_query($tempstr,$dbh);  
}  
?>  
<table width="100%" border="0">  
<tr class="text">   
<td width="50%">  <p align="left">当前位置:主页——论坛——论坛内容</p> </td>  
<td width="50%">  <p align="center">&nbsp</p> </td>  
</table>  
<?  
    $tempstr = " select title,readcount,replycount from fr_t_forumtitle where id = ".$theme_id;  
     $res=mysql_query($tempstr,$dbh);    
    $row=mysql_fetch_array($res);    
    $ls_theme_title = $row["title"];    
    $li_readcount   = $row["readcount"];    
    $li_replycount  = $row["replycount"] + 1;    
?>  
<table width="100%" border="0">  
  <tr>   
    <td width="61%" class="text">主题:<span class="text"><font color="#ff0000">  
      <?  
        print $ls_theme_title;  
      ?>  
    </font></span></td>  
    <td width="13%">   
      <p align="center"><a href="addforum.php?theme_id=0" target="_top"><img src="post.gif" width="80" height="20" alt="加新贴字" border="0"></a></p>  
    </td>  
    <td width="13%">   
    <?  
      print &#39;<p align="center"><a href="addforum.php?theme_id=&#39;.$theme_id.&#39;"&#39;;  
      print &#39;target="_top"><img src="reply.gif" width="80" height="20"&#39;;  
      print &#39;alt="回复贴字" border="0"></a></p>&#39;;  
    ?>  
    </td>  
    <td width="13%">   
      <p align="center"><a href="mainforum.php" target="_top"><img src="theme.gif" width="80" height="20" alt="主题列表" border="0"></a></p>
</td>  
  </tr>  
  <tr>   
    <td width="390" class="text">共有帖子 <font color="#ff0000">  
    <?  
     print $li_replycount;  
    ?>  
    </font> 个,已阅读 <font color="#ff0000">  
    <?  
     print $li_readcount;  
    ?>  
    </font> 次</td>  
    <td colspan="3"> </td>  
  </tr>  
</table>  
<?  
//显示帖子的所有内容  
$ls_query = &#39;select content,replyman,replytime,replyemail,replyhttp,replyface from fr_t_forumcontent &#39;;  
$ls_query =  $ls_query. &#39; where id = &#39;.$theme_id.&#39; order by replytime&#39;;  
$res = mysql_query($ls_query, $dbh);   
$li_tempr = 0;  
while ($row = mysql_fetch_array($res)) {   
  if ($li_tempr == 0) {  
  $li_tempr = 1;    
  print &#39;<table width="100%" border="0" bgcolor="#CCCCCC">&#39;;  
  print &#39;  <tr bgcolor="#dedede" bordercolor="#CCCCFF"> &#39;;  
  print &#39; <td class="text" height="19" valign="top" width="5%"> <p align="left">&#39;;  
  print &#39;  <img src="icon&#39;.$row["replyface"].&#39;.gif" width="18" height="18" ></p> </td>&#39;;  
  print &#39;    <td class="text" height="19" valign="top" width="20%"> &#39;;  
  print &#39;      <p align="left"><font color="#3333FF">作者:&#39;.$row["replyman"].&#39;</font></p>&#39;;  
  print &#39;    </td>&#39;;  
  print &#39;    <td class="text" height="19" valign="top" width="25%">&#39;;  
  print  &#39; <font color="#3333FF">发表于:&#39;.$row["replytime"].&#39;</font></td>&#39;;  
  print &#39;    <td class="text" height="19" valign="top" width="25%">&#39;;  
  print &#39; <font color="#3333FF">E_mail:&#39;.$row["replyemail"].&#39;</font></td>&#39;;  
  print &#39;    <td class="text" height="19" valign="top" width="25%">&#39;;  
  print &#39;<font color="#3333FF">&#39;.$row["replyhttp"].&#39; </font></td>&#39;;  
  print &#39;  </tr>&#39;;  
  print &#39;  <tr bgcolor="#dedede" bordercolor="#CCCCFF"> &#39;;  
  print &#39;    <td class="text" height="22" valign="top" colspan="5"> &#39;;  
  print &#39;      <p><font color="#3333FF">&#39;.$row["content"].&#39;</font></p>&#39;;  
  print &#39;    </td>&#39;;  
  print &#39;  </tr>&#39;;  
  print &#39;</table>&#39;;  
  }  
  else {  
$li_tempr = 0;    
print &#39;<table width="100%" border="0" bgcolor="#CCCCCC">&#39;;  
print &#39;  <tr bgcolor="#ededed"> &#39;;  
print &#39; <td class="text" height="19" valign="top" width="5%"> <p align="left">&#39;;  
print &#39;  <img src="icon&#39;.$row["replyface"].&#39;.gif" width="18" height="18" ></p> </td>&#39;;  
print &#39;    <td class="text" height="19" valign="top" width="20%" bgcolor="#ededed"> &#39;;  
print &#39;      <p align="left"><font color="#000099">作者:&#39;.$row["replyman"].&#39;</font></p>&#39;;  
print &#39;    </td>&#39;;  
print &#39;    <td class="text" height="19" valign="top" width="25%">&#39;;  
print &#39; <font color="#000099">发表于:&#39;.$row["replytime"].&#39; </font></td>&#39;;  
print &#39;    <td class="text" height="19" valign="top" width="25%">&#39;;  
print &#39;<font color="#000099">E_mail:&#39;.$row["replyemail"].&#39;</font></td>&#39;;  
print &#39;    <td class="text" height="19" valign="top" width="25%">&#39;;  
print &#39;<font color="#000099">&#39;.$row["replyhttp"].&#39; </font></td>&#39;;  
print &#39;  </tr>&#39;;  
print &#39;  <tr bgcolor="#ededed"> &#39;;  
print &#39;    <td class="text" height="22" valign="top" colspan="5"> &#39;;  
print &#39;      <p><font color="#000099">&#39;.$row["content"].&#39;</font></p>&#39;;  
print &#39;    </td>&#39;;  
print &#39;  </tr>&#39;;  
print &#39;</table>&#39;;  
}  
}  
?>  
<?  
  include ("c:mydbfooter.inc");  
?>  
</HTML>
Copier après la connexion

---------- 
http://www.php.cn/ 

source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!