社区(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 相关文章推荐
PHP4之COOKIE支持详解
Oct 09 PHP
php Smarty模板生成html文档的方法
Apr 12 PHP
分享下页面关键字抓取www.icbase.com站点代码(带asp.net参数的)
Jan 30 PHP
常用PHP框架功能对照表
Oct 23 PHP
PHP比你想象的好得多
Nov 27 PHP
详解WordPress中简码格式标签编写的基本方法
Dec 22 PHP
php正则修正符用法实例详解
Dec 29 PHP
PHP实现的折半查找算法示例
Dec 19 PHP
实例讲解PHP页面静态化
Feb 05 PHP
PHP实现微信申请退款功能
Oct 01 PHP
实例讲解PHP中使用命名空间
Jan 27 PHP
php 使用 __call实现重载功能示例
Nov 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实现动态添加XML中数据的方法
2018/03/30 PHP
php5.x禁用eval的操作方法
2018/10/19 PHP
PHP基于session.upload_progress 实现文件上传进度显示功能详解
2019/08/09 PHP
yii框架结合charjs实现统计30天数据的方法
2020/04/04 PHP
Laravel框架中队列和工作(Queues、Jobs)操作实例详解
2020/04/06 PHP
IE中jscript/javascript的条件编译
2006/09/07 Javascript
javascript中expression的用法整理
2014/05/13 Javascript
全面了解JavaScript对象进阶
2016/07/19 Javascript
jQuery如何防止Ajax重复提交
2016/10/14 Javascript
javascript另类方法实现htmlencode()与htmldecode()函数实例分析
2016/11/17 Javascript
elementui的默认样式修改方法
2018/02/23 Javascript
微信小程序实现自动定位功能
2018/10/31 Javascript
jQuery实现当拉动滚动条到底部加载数据的方法分析
2019/01/24 jQuery
微信小程序页面上下滚动效果
2020/11/18 Javascript
javascript设计模式 ? 单例模式原理与应用实例分析
2020/04/09 Javascript
python中urllib模块用法实例详解
2014/11/19 Python
解决Python传递中文参数的问题
2015/08/04 Python
简介Python的collections模块中defaultdict类型的用法
2016/07/07 Python
django使用图片延时加载引起后台404错误
2017/04/18 Python
python抓取网页中链接的静态图片
2018/01/29 Python
python批量读取txt文件为DataFrame的方法
2018/04/03 Python
python实现画五角星和螺旋线的示例
2019/01/20 Python
Python3+Appium安装使用教程
2019/07/05 Python
python内置函数sorted()用法深入分析
2019/10/08 Python
python3中pip3安装出错,找不到SSL的解决方式
2019/12/12 Python
python logging添加filter教程
2019/12/24 Python
css3 实现元素弧线运动的示例代码
2020/04/24 HTML / CSS
捷克家电和家具购物网站:OKAY.cz
2020/07/23 全球购物
美国乒乓球设备、配件和服装品牌:Killerspin
2020/06/07 全球购物
工厂会计员职责
2014/02/06 职场文书
美术兴趣小组活动总结
2014/07/07 职场文书
交通肇事罪辩护词
2015/05/21 职场文书
《坐井观天》教学反思
2016/02/18 职场文书
JavaScript数组reduce()方法的语法与实例解析
2021/07/07 Javascript
十大最强妖精系宝可梦,哲尔尼亚斯实力最强,第五被称为大力士
2022/03/18 日漫
Echarts如何重新渲染实例详解
2022/05/30 Javascript