About PHP and MYSQL

WBOY
Release: 2016-08-08 09:33:37
Original
875 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!