In the development of Web site, the author uses php4.0+mysql3.23.38 to establish a variety of applications. Below, take a simple chat room design as an example, introduce the application of Php+mysql in Web development.
1. Overall design
1. 1 Conception and Planning:
The basic principle of the chat room is to store the spoken data transmitted by each user connected to the same page, and then pass all the statements to each user. That is, the database is used to assemble each person's speech, and the data in the database to everyone to realize the function of the chat room.
1. 2 table Design
First use MySQL to create table chat to store users ' speeches:
Copy the Code code as follows:
mysql> CREATE TABLE Chat
(Chtime Datatime,
Nick CHAR (+) is not NULL,
->words CHAR (150));
Only three fields are set in the table, Chtime is the time to speak, Nick is the speaker's nickname, words is the content of the statement, the speech is up to 150 characters
1. 3 Web Design
One of the simplest chat rooms usually requires two page boxes: a page box is a form that the user enters to speak, and the other is used to show the speakers. So the code snippet usually requires at least the following segments:
Build the structure of the page frame (main.php)
Procedural section showing members ' statements (cdisplay.php)
Program segment for transmitting user statements (speak.php)
User login into the chat room program segment (login.php)
2. Code Design
When the above planning is complete, you can start code design, using PHP can be very concise implementation of the above functions.
2. 1 User Login login.php, this section of code is a full HTML page
Copy the Code code as follows:
User Login
Please enter your nickname
After completing the above work, a simple chat room production is completed. Of course, the designer can do some personalized design according to personal interests, such as adding a page box, display the current chat room staff list, add expression, get speaker IP, further beautify the page and so on.
http://www.bkjia.com/PHPjc/314593.html www.bkjia.com true http://www.bkjia.com/PHPjc/314593.html techarticle in the development of Web site, the author uses php4.0+mysql3.23.38 to establish a variety of applications. Below, take a simple chat room design as an example, introduce the application of Php+mysql in Web development. 1. Overall ...