Message board can be said to be all PHP beginners will practice a small web application, below I write a PHP message board instance I wrote to all of you, there is a need to understand the students can enter the reference.
1. Create a folder named "Msgboard" in the root directory of your PHP.
Create a "msglist.php" file under "Msgboard"
Data table structure you can import directly
The code is as follows |
Copy Code |
CREATE TABLE ' Msgboard ' ( ' id ' int (ten) is not NULL auto_increment, ' username ' varchar (CHARACTER SET latin1 not NULL, ' Sex ' tinyint (1) Not NULL DEFAULT ' 1 ', ' msg ' text CHARACTER SET latin1 not NULL, PRIMARY KEY (' id ') ) Engine=myisam auto_increment=1 DEFAULT Charset=utf8; |
msglist.php file, including message add, delete, modify
The code is as follows |
Copy Code |
My message board
$username = isset ($_request[' username ')? $_request[' username ': '; Name $sex = isset ($_request[' sex ')? Intval ($_request[' sex '): 1; Gender $msg = isset ($_request[' msg ")? $_request[' msg ']: '; Message
Mysql_connect ("127.0.0.1", "root", "Lzy"); Link mysql_select_db ("test"); Select Database
if (!empty ($username) &&!empty ($msg)) { mysql_query ("INSERT into Msgboard (username,sex,msg) VALUES (' $username ', ' $sex ', ' $msg ')"); } Else { echo "Input not correct "; }
$source = mysql_query ("select * from Msgboard ORDER by ID DESC"); $result = Array ();
?>
Name |
Gender |
Message content |
while ($row = Mysql_fetch_array ($source)) {echo '
' . $row [' username ']. ' | '; Echo '
' . ($row [' sex '] = = 1? ' Male ': ' Female '). ' | '; Echo '
' . $row [' msg ']. ' | '; }?>
|
A PHP message board instance download: Http://file.bKjia.c0m/download/2013/06/08/msgboard.rar
http://www.bkjia.com/PHPjc/628748.html www.bkjia.com true http://www.bkjia.com/PHPjc/628748.html techarticle Message board can be said to be all PHP beginners will practice a small web application, below I write a PHP message board instance I wrote to you, there is need to understand the same ...