社区(php&&mysql)二

function sdatetime($str){
    $str=ereg_replace("-","/",$str);
    $str=substr($str,5,strlen($str)-8);
    return $str;
}

function reAnum($sid){ //羆莱絞计
    $DROOT=getenv('DOCUMENT_ROOT');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    $qsql="SELECT id from bbs_docs where sid='$sid'";
    $rs=mysql_db_query($sql['db'],$qsql);
    return mysql_num_rows($rs);
}

function pagebar($pages) {
    global $pgno;
    //global $pages;
    global $PHP_SELF;
    global $aid;
    global $OPEN_LIST;
    echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center bgcolor='#6CA6CD' class='num'>";
    echo "<tr><td>";
    if($pgno!=0) {
        $pu=$pgno-1;
        echo "<a href=$PHP_SELF?aid=$aid&pgno=$pu>[]</a>";         
    }     
    if($pgno<$pages) {
        $pd=$pgno+1;
        echo "<a href=$PHP_SELF?aid=$aid&pgno=$pd>[]</a>";         
    }     
    for($i=0;$i<=$pages;$i++) {
        if($pgno==$i) {
            echo "<b>";
            echo "[".($i+1)."]";
            echo "</b>";     
        } else {
            echo "<a href=$PHP_SELF?aid=$aid&pgno=$i>";
            echo "[".($i+1)."]";
            echo "</a>";     
        }
    }
    echo "</td>";
    echo "<TD align=right>";
        echo "<a href=$PHP_SELF?proc=view&aid=$aid>";
                echo "[祇ゅ彻]";
                echo "</a>";
    //echo "</TD>";
    //echo "<TD align=right>";
            if($OPEN_LIST) {
                echo "<a href=$PHP_SELF?proc=colloff&aid=$aid&pgno=$pgno>";
                echo "[ぃ甶秨杠肈]";
                echo "</a>";
            }else {
                echo "<a href=$PHP_SELF?proc=collon&aid=$aid&&pgno=$pgno>";
                echo "[甶秨杠肈]";
                echo "</a>";
            }
    echo "</TD>";         
    echo "</tr></table>";

}
//===============================================================================
function openlist($sid) {
    global $aid;
    global $PHP_SELF;

$DROOT=getenv('DOCUMENT_ROOT');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    $qsql="SELECT * from bbs_docs where sid='$sid' order by wdate";
    $rs=mysql_db_query($sql['db'],$qsql);
    //if(mysql_num_rows($rs)==0) return;
    //echo  mysql_num_rows($rs);
    while($row=mysql_fetch_array($rs)) {
        $id=$row['id'];
            $banner=$row['banner'];
            $poster=$row['poster'];
            $views=$row['views'];
            $wdate=sdatetime($row['wdate']);

echo "<tr bgcolor='#F0F0F0'>";
                echo "<td>";
                    echo "<a href=$PHP_SELF?proc=view&aid=$aid&sid=$sid&rid=$id>";
                    echo "  <font color=#836FFF>$banner</font>";
                    echo "</a>";
                    //echo "banner is $banner";
                echo "</td>";
                echo "<td>";
                    echo $poster;
                echo "</td>";
                echo "<td class='num'>";
                    echo " ";
                echo "</td>";
                echo "<td class='num'>";
                    echo $views;
                echo "</td>";
                echo "<td class='num'>";
                    echo $wdate;
                echo "</td>";

echo "</tr>";
    }

}

//========================================================================
function area() {
    global $PHP_SELF;
    global $aid,$sid,$pgno;
    global $OPEN_LIST;
    $showitems=20;
    $DROOT=getenv('DOCUMENT_ROOT');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    //============================================================
    if(!$aid) {
          $qsql="SELECT id from bbs_area";
          $rs=mysql_db_query($sql['db'],$qsql);
          $row=mysql_fetch_array($rs);
          $aid=$row['id'];               
        }
    if(!$sid) {
        $qsql="SELECT id from bbs_subj where aid=$aid order by wdate DESC";
        $rs=mysql_db_query($sql['db'],$qsql);
        $row=mysql_fetch_array($rs);
        $sid=$row['id'];     
    }

if(!$pgno) {//礚﹚计
        //$pgno=0;  
        $items=0;
        $qsql="SELECT id from bbs_subj where aid=$aid order by wdate DESC";
        $rs=mysql_db_query($sql['db'],$qsql);
        while($row=mysql_fetch_array($rs)){
            $id=$row['id'];     
            if($id==$sid) break;
            $items++;
        }
        $pgno=(INT)($items/$showitems);         
    }

//============================================================
    $qsql="SELECT * from bbs_area where id=$aid ";
    $rs=mysql_db_query($sql['db'],$qsql);
    $row=mysql_fetch_array($rs);
    $banner=$row['banner'];
    $body=$row['body'];
    $master=$row['master'];
    echo "<center><font color=GREEN size=5><b>$banner</b></font></center>";

echo "<FORM  name=mtab  ENCTYPE=multipart/form-data METHOD=POST ACTION=$PHP_SELF?proc=search>";
    echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center class='tablefont'>";
      echo "<tr><td>";

echo "<input type='hidden' name=aid value='$aid'>";     
              echo "穓碝ゅ彻:";
              echo "<INPUT TYPE='TEXT' NAME='key' size=25 class='tablefont'>";
              echo "<INPUT TYPE='Submit'value='琩高' class='tablefont'>";

echo "</td></tr>";
    echo "</table>";  
    echo "</FORM>";

$qsql="SELECT * from bbs_subj where aid=$aid order by wdate DESC";
    $rs=mysql_db_query($sql['db'],$qsql);
    $all=mysql_num_rows($rs);  //how rows
    $pages=(INT)($all/$showitems); // how pages
    $pgcount=$pgno*$showitems;
    if($pgcount > $all) {  
        $pgno=$pages-1; // Page point over all pages
        $pgcount=$pgno*$showitems;
     }
    mysql_data_seek($rs, $pgcount);
    $cnt=0;
    pagebar($pages);
    echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center bgcolor='#6CA6CD'>";
      echo "<tr><td>";
      echo "<TABLE width=100% cellPadding=1 cellSpacing=1 bgcolor=white class='tablefont'>";
        echo "<tr bgcolor=#F1E1FF>";
            echo "<th >夹肈</th>";
            echo "<th>祇癬</th>";
            echo "<th width=30>莱</th>";
            echo "<th width=30></th>";
            echo "<th width=70>ら戳</th>";
        echo "</tr>";
        while($row=mysql_fetch_array($rs)) {
            if(++$cnt > $showitems) break;
            $id=$row['id'];
            $banner=$row['banner'];
            $poster=$row['poster'];
            $views=$row['views'];
            $wdate=sdatetime($row['wdate']);
            $docs=reAnum($id);
            echo "<tr bgcolor='#F0F8FF'>";
                echo "<td>";
                    echo "<a href=$PHP_SELF?proc=view&aid=$aid&sid=$id&rid=$id>";
                        if($sid==$id) echo "<font color=red>〈$banner</font>";
                        else echo $banner;
                    echo "</a>";
                echo "</td>";
                echo "<td>";
                    echo $poster;
                echo "</td>";
                echo "<td class='num'>";
                    echo $docs;
                echo "</td>";
                echo "<td class='num'>";
                    echo $views;
                echo "</td>";
                echo "<td class='num'>";
                    echo $wdate;
                echo "</td>";
            echo "</tr>";
            if($OPEN_LIST) openlist($id);
        }
      echo "</td></tr></table>";
    echo"</td></tr></table>";

pagebar($pages);
}
待续........

(0)

相关推荐

  • 社区(php&&mysql)二

    function sdatetime($str){     $str=ereg_replace("-","/",$str);     $str=substr($str,5,strlen($str)-8);     return $str; } function reAnum($sid){ //羆莱絞计     $DROOT=getenv('DOCUMENT_ROOT');     include("sql.php3");     $db=mys

  • win10 下安装mysql服务器社区版本mysql 5.7.22 winx64的图文教程

    下载: http://dev.mysql.com/downloads/mysql/ 解压到C盘 添加环境变量path 添加环境变量 右击我的电脑->属性->高级系统设置->高级->环境变量-> 在系统变量中找到变量Path,点击编辑,在变量值最后面添加解压路径,路径要到bin文件夹下的路径,如: 以管理员权限运行cmd 安装MySQL服务 在cmd 命令窗口下 输入 mysqld install 初始化mysql数据库,这时会创建刚刚配置的data目录和一些数据库系统用的基本

  • 聊天室php&mysql(二)

    //第二页面 name="frame2.php" <? include "../signup/mysql.php"; header("Expires: Sun, 28 Dec 1997 09:32:45 GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("

  • 社区(php&&mysql)一

    function cook_cooloff(){     global $PHP_SELF,$aid,$pgno;     setcookie("OPEN_LIST",0,time()+ 31536000);     Header("Location:$PHP_SELF?aid=$aid&pgno=$pgno");     exit; } //==========================================================

  • 社区(php&&mysql)五

    function post2() {     global $sid,$aid,$PHP_SELF;     global $banner,$body,$poster,$email,$type,$CHAR_GB; if(strlen($banner)==0 || strlen($body)==0 || strlen($poster)==0 || strlen($email)==0) {         echo "           <script language=javascript

  • 社区(php&&mysql)四

    echo "<br>";     echo "<TABLE width=85% border=0 cellPadding=0 cellSpacing=1 align=center bgcolor='#6CA6CD'>";       echo "<tr><td>";       echo "<TABLE width=100% cellPadding=1 cellSpacing=1 b

  • 社区(php&&mysql)三

    function prev_subj($id){     $DROOT=getenv('DOCUMENT_ROOT');     include("sql.php3");     $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);      $qstr="select id,aid from bbs_subj where id='$id'";     $rs=mysql_db_query($

  • 社区(php&&mysql)六

    //此为bbs.sql CREATE TABLE bbs_area (    id int(10) unsigned DEFAULT '0' NOT NULL auto_increment,    master varchar(150) NOT NULL,    banner varchar(150) NOT NULL,    body text NOT NULL,    email varchar(50),    login varchar(20),    passwd varchar(20)

  • MySql 8.0.11安装配置教程

    官网地址:https://dev.mysql.com/downloads/mysql/ 我这里是RHEL6.5的系统,因此选择RedHat 6 x86,64bit操作系统---下载第一个RPM Bundle即可--mysql-8.0.11-1.el6.x86_64.rpm-bundle.tar. 目前MySQL8.0.11社区版提供了多种多样的安装方式,但是并未发现针对Linux Generic安装包包含的mysql_secure_installation的安装说明. 因此这里使用推荐的RPM安

  • MySQL数据库简介与基本操作

    目录 一.MySQL简介 1.数据库管理软件分类 2.MySQL 二.存储引擎(也称作表类型) 1.常用存储引擎及适用场景 2.存储引擎在mysql中的使用 1. 在建表时指定存储引擎 2 .在配置文件中指定存储引擎 三.MySQL表操作 1.查看表结构 2.自动增长列 四 .MySQL支持的数据类型 1.ENUM和SET类型 2.set/enum示例 五.MySQL表查询 1.限制查询的记录数(limit) 2.使用正则表达式查询 六.数据备份(命令行) 1. 数据库的逻辑备份 2. 数据恢复

随机推荐