ÉçÇø(php&&mysql)¶þ

5年以前  |  阅读数:458 次  |  编程语言:PHP 

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

function reAnum($sid){ //Á`¦^À³½g¼Æ
$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 "

";
echo "";
echo "";
//echo "";
echo "
";
if($pgno!=0) {
$pu=$pgno-1;
echo "<a href=$PHP_SELF?aid=$aid&pgno;=$pu>[¤W¤@­¶]";
}
if($pgno<$pages) {
$pd=$pgno+1;
echo "<a href=$PHP_SELF?aid=$aid&pgno;=$pd>[¤U¤@­¶]";
}
for($i=0;$i<=$pages;$i++) {
if($pgno==$i) {
echo "";
echo "[".($i+1)."]";
echo "
";
} else {
echo "<a href=$PHP_SELF?aid=$aid&pgno;=$i>";
echo "[".($i+1)."]";
echo "";
}
}
echo "
";
echo "<a href=$PHP_SELF?proc=view&aid;=$aid>";
echo "[µoªi¤a³¹]";
echo "";
//echo "
";
if($OPEN_LIST) {
echo "<a href=$PHP_SELF?proc=colloff&aid;=$aid&pgno;=$pgno>";
echo "[¤£®i¶}¸ÜÃD]";
echo "";
}else {
echo "<a href=$PHP_SELF?proc=collon&aid;=$aid&&pgno;=$pgno>";
echo "[®i¶}¸ÜÃD]";
echo "";
}
echo "
";

}
//===============================================================================
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) {//µL«u(C)w­¶¼Æ   
    //$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 "*j´M¤a³¹:";   
          echo "<INPUT TYPE='TEXT' NAME='key' size=25 class='tablefont'>";   
          echo "<INPUT TYPE='Submit'value='¬d¸ß' 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 >¼ÐÃD</th>";   
        echo "<th>µo°_¤H</th>";   
        echo "<th width=30>¦^À³</th>";   
        echo "<th width=30>¤H®ð</th>";   
        echo "<th width=70>¤e´Á</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分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例