By combining PHP and MySQL reasonably and effectively, you 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 several other databases including PostgreSQL.
Here is an example:
First of all, 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")."
n";
echo "Author: ".mysql_result($result,0,"author")."
n";
echo "PRice: ".mysql_result($result,0,"price")."
n";
?>
The function mysql_connect() refers to connecting to a MYSQL server on the specified host through the user name (or the specified password). The variable $db is used to submit this connection. .
mysql_select_db() specifies the database to be used in subsequent queries. The function mysql_query() sends 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.
The above has introduced PHP and MYSQL, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.