In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about PHP visiting MySQL, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
In this chapter we will learn how to store information in a Web page in a database and display it. We have installed MySQL, a relational database engine, and PHP, a server-side scripting language, and learned the basics of them. After learning this chapter, we will understand how to use these two new tools to build a database-driven website!
Before we move on, it should be valuable to review the purpose of our study. Now we have two powerful new tools in our system: the scripting language PHP and the database engine MySQL. It is important to figure out if the two work together. The essence of a database-driven website is to allow the content of the site to exist in a database, and through this database to dynamically generate Web pages to allow our visitors to display it through a standard Web browser. So at one end of your system is a visitor to your site who visits http://www.yoursite.com/ to get a standard Web page in HTML format and display it in a Web browser. At the other end of your system is the content of your site stored through one or more tables in a MySQL database that only understands how to respond to SQL queries (commands). The PHP scripting language acts as a liaison between the two. With PHP, you can write a standard HTML "template" that determines the appearance of your site (including pictures and page designs). At this point, the content belongs to this "template". You can use some PHP code to connect to the MySQL database and use the SQL query to get the data and display it in its corresponding location. The SQL query here is the same as when we used to build the joke data sheet in Chapter 2. Now you should have a clear idea of what happens when a visitor visits a page of your database-driven website: the visitor's Web browser requests the page using a standard URL. The Web server software (Apache, IIS, or others) determines that the requested page is an PHP script and interprets it with its PHP plug-in before responding to the page request. Some PHP commands (we haven't learned yet) connect to the MySQL database and ask the database for content that belongs to this Web page. The MySQL database responds and sends the requested content to the PHP script. The PHP script stores the content in one or more PHP variables and outputs it as part of the Web page using the familiar echo function. The PHP plug-in completes the processing and returns the resulting copy of HTML to the Web server. The Web server sends this copy of HTML to the Web browser, which will be a standard HTML file, except that it comes not directly from a HTML file, but from the output provided by the PHP plug-in. Connect to MySQL with PHP before we can get the content of our Web page from our MySQL database, we must first know how to establish a connection to MySQL. In the second chapter, we use a program called mysql to make such a connection. PHP does not need such a program, and support for connecting to MySQL is built into the language. The following function is used to establish such a connection:
QUOTE: the above is PHP's visit to MySQL. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.