Everyone can do PHP simple message board

Source: Internet
Author: User
PHP version of the simple message board ...
Before writing a simple message board ... Use PHP to match MySQL
A total of 3 documents (gb_view.php, gb_add.htm, gb_check.php) are required
MySQL table Please create a new field (name, comment)

1.gb_view.php writing//Link database Related Settings
Mysql_connect (database location, ' Database account ', ' Database Password ');
$database = "database name";
$tablename = "table name";
Enter SQL Check syntax
$dataresult =mysql ($database, "SELECT * from $tablename Order BY field DESC");
Variable rownum as the total number of data
$rownum =mysql_numrows ($dataresult);
Set Variable I read data from DB using cyclic structure
$i = 0;
while ($i < $rownum)
{
Reading data under the Name&comment field in db
Echo mysql_result ($dataresult, $i, "name");
The following NL2BR () is a function that breaks the break
Echo nl2br (mysql_result ($dataresult, $i, "comment")); $i + +;
Loop End
Copy Code 2.gb_add.htm Input page writing this page as a general input form just fine ... This is not much to say.
After the page design, remember to point the target to the processing page (gb_check.php)
3.gb_check.php data processing writing//link database Related Settings
Mysql_connect (database location, ' Database account ', ' Database Password ');
$database = "database name";
$tablename = "table name";
Write the variable no as the index of the data in the database
$Builddata = "INSERT into $tablename values (' $ No ', ' $ Name ', ' $ Comment ')";
$create =mysql ($database, $Builddata); Copy code is done!! Done!!
Such a simple message board is done!!
Later of course can also join the moderator reply, whispering and other advanced functions

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.