资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 编程开发 >
Advertisement
文章正文

一个在PHP中利用递归实现论坛分级显示的例子(为了简单起见,我将分页显示部分去掉了)_编程

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   
  • 编译apache2.0.54源代码时的log 
  • 关于project2003与excel宏 
  • 用PHP控制用户的浏览器--ob*函数的使用 
  • Remedy是啥玩意儿? 
  • 编写测试用例有些时候可以采用随机战略 
  • XP的测试用例在函数内部有assert情况下不能反映接口的全部信息 
  • VB函数查询(二) 
  • 浅谈地址映射原理与举例分析 
  • Java开发人员书房必备的图书 
  • 程序结构的7个证明原理 
  • 页面导航:

    正文内容:
    <?php
    /*存放帖子的表结构
    create table announce (
     announce_id int(11) not null auto_increment,
     board_id smallint(6) not null,
     title varchar(100) not null,
     content tinytext,
     add_time datetime default 0000-00-00 00:00:00 not null,
     auth_name varchar(20) not null,
     auth_mail varchar(40),
     hit_count smallint(6) not null,
     bytes mediumint(9) not null,
     parent_id tinyint(4) not null,
     auth_ip varchar(15) not null,
     top_id int(11) not null,
     return_count tinyint(4) not null,
     face char(3) not null,
     primary key (announce_id),
     key board_id (board_id),
     key top_id (top_id)
    );
    */

    function show_announce($id,$self_id){
     global $dbconnect;
     global $board_id;
     $query="select * from announce where announce_id=$id";
     $result=mysql_query($query,$dbconnect);
     $myrow=mysql_fetch_array($result);
     mysql_free_result($result);
     echo "<li>\n";
     echo "<img src=images/mood".$myrow[face].".gif> ";
     if($self_id!=$id)
     echo "<a href=show.php3?board_id=$board_id&announce_id=$myrow[announce_id]&top_id=$myrow[top_id]>";
     echo $myrow[title];
     if($self_id!=$id)
     echo "</a>";
     echo " - <strong>【".$myrow[auth_name]."】</strong> ".$myrow[add_time]." <font color=darkblue>[id:$myrow][announce_id] 点击:$myrow[hit_count]]</font> ($myrow[bytes] bytes) <font color=red>($myrow[return_count])</font>\n";
     $query="select announce_id from announce where parent_id=$id order by announce_id desc";
     $result=mysql_query($query,$dbconnect);
     echo "<ul>\n";
     while($myrow=mysql_fetch_array($result)){
     show_announce($myrow[announce_id],$self_id);
     }
     echo "</ul>\n";
     mysql_free_result($result);
     echo "</li>";
    }
    ?>

    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=gb2312">
     <title>论坛内容</title>
    <link rel="stylesheet" type="text/css" href="common.css">
    </head>

    <body>
    <?php
    //此处需要连接数据库
    //可以根据需要加入分页
    $query="select announce_id from announce where top_id=0 order by announce_id desc ";
    $result_top=mysql_query($query,$dbconnect);
    echo "<ul>\n";
    while($myrow_top=mysql_fetch_array($result_top)){
     show_announce($myrow_top[announce_id],0);
    }
    echo "</ul>\n";
    mysql_free_result($result_top);
    ?>
    </body>
    </html>

     

     
    热门推荐笔记本: IBM笔记本
    相关文章:
    webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
    ©2007 popbb.net All Rights Reserved