PHP and MYSQL databases can be reasonably and effectively combined _ PHP Tutorial

Source: Internet
Author: User
A rational and effective combination of PHP and MYSQL databases. Combine PHP and MYSQL reasonably and effectively to create a sophisticated database website. MYSQL is a small, tight data server that supports standard SQL. It combines PHP and MYSQL reasonably and effectively in the UNIX and WINDOWS environment to create a sophisticated database website. MYSQL is a small, tight data server that supports standard SQL. It can be used in both UNIX and WINDOWS environments.

PHP and MYSQL are free open source code. Their combination can be developed in WINDOWS and serve in UNIX. PHP also supports other databases, including PostgreSQL.

The following is an example:

First, you have installed PHP and MYSQL. this simple script example reads data from the database and then displays it.

<html><body><?php $db = mysql_connect("localhost", "root"); mysql_select_db("mydb", $db); $result = mysql_query("SELECT * FROM books",$db); echo "Title: ".mysql_result($result,0,"title")."<br>n"; echo "Author: ".mysql_result($result,0,"author")."<br>n"; echo "Price: ".mysql_result($result,0,"price")."<br>n"; ?></body></html>

The mysql_connect () function is used to connect to a MYSQL server on the specified host using the user name (or password. The variable $ db is used to submit this connection ..

Mysql_select_db () specifies the question behind the database. The mysql_query () function sends an SQL question to MySQL for execution. The result is returned and stored in the variable $ result.

Finally, the mysql_result () function is used to obtain the result.


Bytes. MYSQL is a small, tight data server that supports standard SQL. It is in the UNIX and WINDOWS environment...

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.