Community (php & amp; mysql) 2

Source: Internet
Author: User

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 "[restricted]";
Echo "</a> ";
// Echo "</TD> ";
// Echo "<TD align = right> ";
If ($ OPEN_LIST ){
Echo "<a href = $ PHP_SELF? Proc = colloff & aid = $ aid & pgno = $ pgno> ";
Echo "[too many parallel Bars]";
Echo "</a> ";
} Else {
Echo "<a href = $ PHP_SELF? Proc = collon & aid = $ aid & pgno = $ pgno> ";
Echo "[parallel Parallel Bars]";
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) {// Counter
// $ 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 = 'ddn' name = aid value = '$ aid'> ";
Echo "too many referers :";
Echo "<input type = 'text' NAME = 'key' size = 25 class = 'tablefont'> ";
Echo "<input type = 'submit 'value = 'partition height' 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> clip </th> ";
Echo "<th> only exist </th> ";
Echo "<th width = 30> Lai </th> ";
Echo "<th width = 30> </th> ";
Echo "<th width = 70> signature stamp </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 );
}
To be continued ........

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.