社区(php&&mysql)二


Posted in PHP onOctober 09, 2006

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);
}
待续........ 

PHP 相关文章推荐
一个基于PDO的数据库操作类(新) 一个PDO事务实例
Jul 03 PHP
PHP mcrypt可逆加密算法分析
Jul 19 PHP
PHP mb_convert_encoding文字编码的转换函数介绍
Nov 10 PHP
SESSION信息保存在哪个文件目录下以及能够用来保存什么类型的数据
Jun 17 PHP
PHP优于Node.js的五大理由分享
Sep 15 PHP
PHP 常用数组内部函数(Array Functions)介绍
Jun 05 PHP
在WordPress中使用PHP脚本来判断访客来自什么国家
Dec 10 PHP
今天你说520了吗?不仅有php表白书还有java表白神器
May 20 PHP
ThinkPHP3.2.1图片验证码实现方法
Aug 19 PHP
用php+ajax新建流程(请假、进货、出货等)
Jun 11 PHP
Laravel 5.4重新登录实现跳转到登录前页面的原理和方法
Jul 13 PHP
PHP单例模式应用示例【多次连接数据库只实例化一次】
Dec 18 PHP
社区(php&amp;&amp;mysql)一
Oct 09 #PHP
如何在PHP中使用Oracle数据库(6)
Oct 09 #PHP
如何在PHP中使用Oracle数据库(5)
Oct 09 #PHP
如何在PHP中使用Oracle数据库(4)
Oct 09 #PHP
人大复印资料处理程序_补充篇
Oct 09 #PHP
如何在PHP中使用Oracle数据库(3)
Oct 09 #PHP
人大复印资料处理程序_输入篇
Oct 09 #PHP
You might like
PHP Socket 编程
2010/04/09 PHP
ThinkPHP中order()使用方法详解
2016/04/19 PHP
mysql desc(DESCRIBE)命令实例讲解
2016/09/24 PHP
PHP实现的字符串匹配算法示例【sunday算法】
2017/12/19 PHP
JavaScript 继承详解(三)
2009/07/13 Javascript
div拖拽插件——JQ.MoveBox.js(自制JQ插件)
2013/05/17 Javascript
原生JavaScript实现合并多个数组示例
2014/09/21 Javascript
jquery实现的蓝色二级导航条效果代码
2015/08/24 Javascript
node.js回调函数之阻塞调用与非阻塞调用
2015/11/13 Javascript
Angular 路由route实例代码
2016/07/12 Javascript
javascript实现的左右无缝滚动效果
2016/09/19 Javascript
AngularJS解决ng界面长表达式(ui-set)的方法分析
2016/11/07 Javascript
基于JQuery及AJAX实现名人名言随机生成器
2017/02/10 Javascript
js中作用域的实例解析
2017/03/16 Javascript
JavaScript使用原型和原型链实现对象继承的方法详解
2017/04/05 Javascript
ionic实现下拉刷新载入数据功能
2017/05/11 Javascript
Node.js 实现简单的接口服务器的实例代码
2017/05/23 Javascript
AngularJS 中的数据源的循环输出
2017/10/12 Javascript
在一个页面实现两个zTree联动的方法
2017/12/20 Javascript
解决Jquery下拉框数据动态获取的问题
2018/01/25 jQuery
手写Node静态资源服务器的实现方法
2018/03/20 Javascript
vue组件间的参数传递实例详解
2019/04/26 Javascript
vue操作动画的记录animate.css实例代码
2019/04/26 Javascript
详解vue微信网页授权最终解决方案
2019/06/16 Javascript
Angular.JS读取数据库数据调用完整实例
2019/07/02 Javascript
python使用正则表达式匹配字符串开头并打印示例
2017/01/11 Python
正确理解python中的关键字“with”与上下文管理器
2017/04/21 Python
终端命令查看TensorFlow版本号及路径的方法
2018/06/13 Python
python3+pyqt5+itchat微信定时发送消息的方法
2019/02/20 Python
Python安装与卸载流程详细步骤(图解)
2020/02/20 Python
HealthElement海外旗舰店:新西兰大卖场
2018/02/23 全球购物
屈臣氏菲律宾官网:Watsons菲律宾
2020/06/30 全球购物
大学生职业规划书的范本
2014/02/18 职场文书
考试作弊万能检讨书
2014/10/19 职场文书
四风之害观后感
2015/06/09 职场文书
Django程序的优化技巧
2021/04/29 Python