社区(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 相关文章推荐
memcached 和 mysql 主从环境下php开发代码详解
May 16 PHP
JpGraph php柱状图使用介绍
Aug 23 PHP
php合并js请求的例子
Nov 01 PHP
php随机显示图片的简单示例
Feb 15 PHP
ThinkPHP CURD方法之order方法详解
Jun 18 PHP
ThinkPHP3.1新特性之内容解析输出详解
Jun 19 PHP
php建立Ftp连接的方法
Mar 07 PHP
php解析url并得到url中的参数及获取url参数的四种方式
Oct 26 PHP
PHP识别二维码的方法(php-zbarcode安装与使用)
Jul 07 PHP
php使用正则表达式去掉html中的注释方法
Nov 03 PHP
php生成毫秒时间戳的实例讲解
Sep 22 PHP
CI框架(CodeIgniter)操作redis的方法详解
Jan 25 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
四月新番又没了,《Re:从零开始的异世界生活》第二季延期至7月播出
2020/05/06 日漫
实用函数8
2007/11/08 PHP
php中字符集转换iconv函数使用总结
2014/10/11 PHP
javascript Discuz代码中的msn聊天小功能
2008/05/25 Javascript
javascript取消文本选定的实现代码
2010/11/14 Javascript
Nodejs学习笔记之Global Objects全局对象
2015/01/13 NodeJs
js实现3D图片逐张轮播幻灯片特效代码分享
2015/09/09 Javascript
如何解决easyui自定义标签 datagrid edit combobox 手动输入保存不上
2015/12/26 Javascript
js H5 canvas投篮小游戏
2016/08/18 Javascript
如何在js代码中消灭for循环实例详解
2018/07/29 Javascript
Vue监听一个数组id是否与另一个数组id相同的方法
2018/09/26 Javascript
Vue入门之数量加减运算操作示例
2018/12/11 Javascript
jQuery实现的点击显示隐藏下拉菜单功能完整示例
2019/05/17 jQuery
微信小程序如何实现全局重新加载
2019/06/05 Javascript
Vue全局使用less样式,组件使用全局样式文件中定义的变量操作
2020/10/21 Javascript
Python实现定时任务
2017/02/08 Python
Python使用matplotlib实现绘制自定义图形功能示例
2018/01/18 Python
Windows下将Python文件打包成.EXE可执行文件的方法
2018/08/03 Python
Python线程下使用锁的技巧分享
2018/09/13 Python
将Python字符串生成PDF的实例代码详解
2019/05/17 Python
python用match()函数爬数据方法详解
2019/07/23 Python
No module named ‘win32gui‘ 的解决方法(踩坑之旅)
2021/02/18 Python
瑞贝卡·泰勒官方网站:Rebecca Taylor
2016/09/24 全球购物
英国领先的杂志订阅网站:Magazine.co.uk
2018/01/25 全球购物
linux面试题参考答案(2)
2015/12/06 面试题
幼儿园美术教学反思
2014/01/31 职场文书
红色故事演讲稿
2014/05/22 职场文书
社区党的群众路线教育实践活动领导班子对照检查材料
2014/09/25 职场文书
沈阳故宫导游词
2015/01/31 职场文书
2015年八一建军节慰问信
2015/03/23 职场文书
校长一岗双责责任书
2015/05/09 职场文书
2016入党积极分子心得体会
2016/01/06 职场文书
学习社交礼仪心得体会
2016/01/22 职场文书
Feign调用传输文件异常的解决
2021/06/24 Java/Android
使用Java去实现超市会员管理系统
2022/03/18 Java/Android
Java 定时任务技术趋势简介
2022/05/04 Java/Android