Combining PHP and MYSQL reasonably and effectively can create a refined database website. MYSQL is a small, tight data server that supports standard SQL. It can be used in both UNIX and WINDOWS environments.
Both PHP and MYSQL are free and open source. Their combination can be developed in WINDOWS and serve 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 is to read data from the database and display 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 function mysql_connect() refers to connecting to a MYSQL server on the specified host through the user name (or through the specified password). The variable $db is used to submit this connection. .
mysql_select_db() specifies the database to be used later. The function mysql_query() sends SQL questions to MySQL for execution, and the result is returned and stored in the variable $result.
Finally the mysql_result() function is the result.
Both PHP and MYSQL are free and open source. Their combination can be developed in WINDOWS and serve 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 is to read data from the database and display 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 function mysql_connect() refers to connecting to a MYSQL server on the specified host through the user name (or through the specified password). The variable $db is used to submit this connection. .
mysql_select_db() specifies the database to be used later. The function mysql_query() sends SQL questions to MySQL for execution, and the result is returned and stored in the variable $result.
Finally the mysql_result() function is the result.