A paging Forum

Source: Internet
Author: User
Createtableguest (region, primarykey (id), titlevarchar (50), emailvarchar (30), homepagevarchar (30), namevarchar (30), texttext, relayint, r_timedate) createt --------------------------------- Forum --------------------------
Data table
Create table guest (id int not null auto_increment, primary key (id), title varchar (50), email varchar (30), homepage varchar (30), name varchar (30 ), text, relay int, r_time date)

Create table relay (id int not null auto_increment, primary key (id), title int, email varchar (30), name varchar (30), text)
------------------------- Index. php --------------------------

Website full manual



$ Db = mysql_connect ("localhost ","****","****");

Mysql_select_db ("*****", $ db );

@ $ Result = mysql_query ("SELECT * FROM guest order by id desc", $ db );

$ I = 0;
While ($ myrow = mysql_fetch_row ($ result )){
$ Guestbook [$ I] [0] = $ myrow [0];
$ Guestbook [$ I] [1] = $ myrow [1];
$ Guestbook [$ I] [2] = $ myrow [2];
$ Guestbook [$ I] [3] = $ myrow [4];
$ Guestbook [$ I] [4] = $ myrow [6];
$ Guestbook [$ I] [5] = $ myrow [7];
$ I;
} // Read the array
Mysql_close ($ db );

Echo [";

If ($ q! = ""){
$ Page = $ q;
} Else {
$ Page = 0;
}

$ I = count ($ guestbook );
$ Msgnum = 20; // 20 pens per page
$ Start = $ page * $ msgnum;
$ End = $ start $ msgnum;
If ($ end> $ I) $ end = $ I;
$ Totalpage = $ I/$ msgnum;


For ($ I = 0; $ I <$ totalpage; $ I ){
If ($ I! = $ Page ){
Echo "$ I ";
} Else {
Echo "$ I ";
}
}
Echo "] page -----------------------------
"; Printf ("

Add topic

");
Echo"
";
Echo"



















";Echo" "; Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";For ($ I = $ start; $ I <$ end; $ I ){$ Id = $ guestbook [$ I] [0];Echo" "; Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";}Echo"
TopicEmailNameReplyLast reply time
";
Echo ""; echo $ guestbook [$ I] [1]; echo ""; echo"
";
Echo ""; echo $ guestbook [$ I] [2]; echo ""; echo"
";
Echo $ guestbook [$ I] [3]; echo"
";
Echo $ guestbook [$ I] [4]; echo"
";
Echo $ guestbook [$ I] [5]; echo"
";

Echo"
";

Printf ("add a topic ");


?>
------------------------------ 444. php --------------------------------


$ Db = mysql_connect ("localhost ","****","****");

Mysql_select_db ("*****", $ db );

@ $ Result = mysql_query ("SELECT * FROM guest where id = '$ ID'", $ db );

Echo"


























































";$ Myrow = mysql_fetch_row ($ result );Echo" "; Echo" "; Echo" ";$ Msg = base64_decode ($ myrow [5]);$ Msg = ereg_replace ("", "", $ msg); // space processing$ Msg = nl2br ($ msg); // Line Feed ProcessingIf ($ myrow [3]! = "") {$ Myrow [3] = "$ myrow [3]";}Else{$ Myrow [3] = "I have not settled on the internet ";}Echo" "; Echo" "; Echo" ";Echo" "; Echo" ";Echo" "; Echo" "; Echo" ";$ Num = $ myrow [6];@ $ Result1 = mysql_query ("SELECT * FROM relay where title = '$ ID' order by id desc", $ db );$ I = 0;While ($ myrow1 = mysql_fetch_row ($ result1 )){$ Guestbook [$ I] [0] = $ myrow1 [1];$ Guestbook [$ I] [1] = $ myrow1 [2];$ Guestbook [$ I] [2] = $ myrow1 [3];$ Guestbook [$ I] [3] = $ myrow1 [4];$ I;}Mysql_close ($ db );If ($ q! = ""){$ Page = $ q;} Else {$ Page = 0;}$ I = count ($ guestbook );$ Msgnum = 5; // 5 entries per page$ Start = $ page * $ msgnum;$ End = $ start $ msgnum;If ($ end> $ I) $ end = $ I;$ Totalpage = $ I/$ msgnum;For ($ I = $ start; $ I <$ end; $ I ){$ T = $ guestbook [$ I] [0];Echo" "; Echo" "; Echo" ";Echo" "; Echo" "; Echo" ";Echo" "; Echo" "; Echo" ";$ Msg = base64_decode ($ guestbook [$ I] [3]);$ Msg = ereg_replace ("", "", $ msg );$ Msg = nl2br ($ msg );Echo" "; Echo" "; Echo" ";}Echo"
Topic: "; echo $ myrow [1]; echo"
"; Echo $ msg; echo"
Home page: "; echo $ myrow [3]; echo"
"; Echo" reply list "; echo"
";
Echo "Re:"; echo $ myrow [1]; echo"
";
Echo $ guestbook [$ I] [2]; echo"
Email :";
Echo ""; echo $ guestbook [$ I] [1]; echo ""; echo"
";
Echo $ msg; echo"
"; Echo"
"; Echo"
"; Echo [";
For ($ I = 0; $ I <$ totalpage; $ I ){
If ($ I! = $ Page ){
Echo "$ I ";
} Else {
Echo $ I;
}
} Echo "] page ---------------------------------"; echo"
";
Echo "reply"; echo"
";
Echo "browsing themes ";
?>
-------------------------------- 333. php -----------------------------




If (! $ T ){
If ($ text = "" & $ email = "" & $ name = "") {echo "* required"; echo "return ";}
Else {if (eregi ("^ [_. 0-9a-z-] @ ([0-9a-z] [0-9a-z-].) [a-z] {2, 3} $ ", $ email )){
$ Text = base64_encode ($ text); // check whether the email address is valid
$ Db = mysql_connect ("localhost ","****","****");
$ Time = date ("y-m-d ");
Mysql_select_db ("*****", $ db );
$ SQL = "insert into relay values ('', '$ title',' $ email ',' $ name', '$ text ')";

$ Result = mysql_query ($ SQL );
$ Num = $ num 1;
$ SQL = "update guest set relay = '$ num', r_time =' $ time' where id = '$ title '";
$ Result = mysql_query ($ SQL );
Mysql_close ();


Echo" ";


}
Else {echo "invalid email address"; echo "back ";}
}}
Else
{?>
?>



----------------------------------- Www. php --------------------------



If ($ title! = "" & $ Email! = "" & $ Name! = ""){
If (eregi ("^ [_. 0-9a-z-] @ ([0-9a-z] [0-9a-z-].) [a-z] {2, 3} $", $ email )){
$ Text = base64_encode ($ text); // check whether the email address is valid
$ Db = mysql_connect ("localhost ","****","****");
$ Time = date ("y-m-d ");
Mysql_select_db ("*****", $ db );
$ SQL = "insert into guest values ('', '$ title',' $ email ',' $ homepage', '$ name',' $ text ','', '$ time ')";

$ Result = mysql_query ($ SQL); mysql_close ();



Echo" ";



}
Else
{Echo "invalid email address"; echo "back ";}}

Else {echo "* required"; echo "back ";}

// Mysql_close ($ db)
// Printf ("If the message is successfully sent, return this message ");
?>




-------------------------------- 111. php ---------------------------








[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]

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.