Combining PHP and MYSQL reasonably and effectively can create an exquisite database website. MYSQL is a small, compact data server that supports standard SQL. It can be used in both UNIX and WINDOWS environments.
PHP and MYSQL are both free and open source. Their combination can be developed in WINDOWS and provided services in UNIX. PHP also supports some other databases including PostgreSQL.
Here is an example:
First you have installed PHP and MYSQL. This simple script example reads data from the database and displays it.
$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")."
n";
echo "Price: ".mysql_result($result,0, "price")."
n";
?>
The function mysql_connect() refers to Connect to a MYSQL server on the specified host through the username (you can also specify the password). The variable $db is used to submit this connection. .
mysql_select_db() specifies the database to be used for subsequent questions. The function mysql_query() is to send a SQL query to MySQL for execution, and the result is returned and stored in the variable $result.
Finally, the mysql_result() function is to get the result.
http://www.bkjia.com/PHPjc/315458.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315458.htmlTechArticleThe reasonable and effective combination of PHP and MYSQL can create an exquisite database website. MYSQL is a small, compact data server that supports standard SQL. It works in UNIX and WINDOWS environments...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn