Use PHP and MySQL to build a database-driven website (3)

Source: Internet
Author: User
Tags php file php and php and mysql php code
Summary
In this chapter, we will focus on how to use Structured Query Language (SQL) to work in MySQL databases.
(14:11:10)
--------------------------------------------------------------------------------
By Wing, source: Linuxaid
Chapter 2: Getting started with MySQL
Welcome back to this tutorial! In the previous chapter, we learned how to install and configure PHP and MySQL. In this chapter, we will focus on learning how to use Structured Query Language (SQL) to work in MySQL databases.
Database entry
As described in the previous chapter, PHP is a server-side scripting language. With this language, you can add commands on your Web page, so that your Web service software (probably Apache, personal Web Server or any other software) will execute it before sending these pages to the requesting browser. In that simple example, I show how to insert the current date in the Web page that receives the request each time.
It is clear, but adding a database in it will really interest us. A database server (MySQL here) is a program that stores a large amount of information in a certain format. Through this program, you can easily access data using a script language like PHP. For example, you can use PHP to get a joke list in the database and display it to your Web site.
Jokes are completely stored in the database. There are two benefits to doing so. First, you no longer need to write an HTML file for each joke. You only need to write a php file to extract any joke from the database and display it. Second, to add a joke to your Web site, you just need to add the joke to the database. PHP code automatically displays new jokes when the new joke package is included in the list.
Let's use this example to see how the data is stored in the database. A database contains one or more tables. Each table contains a list of items. For our joke database, we may need a data table named "jokes" at the beginning, which contains a joke list. Each data table in the database contains one or more columns or fields ). Back in our example, our "jokes" data table may have two columns: the joke body and the date the joke was added to the database. Every joke stored in a data table is called a row. To understand all the terms mentioned here, you can refer to the figure below:
In addition to the joke text ("JokeText") and date ("JokeDate") data columns, I also added a data column called "ID. This data column is used to assign a unique number to each joke so that we can easily view and distinguish these jokes.
For details, the data table above contains three data columns and two rows. Each line contains a joke ID, its body, and its addition date. After understanding these basic terms, we will start using MySQL.
Related Article

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.