Integration of PHP with MySQL (How PHP Fits with MySQL)
- MySQL commands within PHP code almost as seamlessly with HTML.
- There are Numerous PHP functions that work specifically with MySQL to make life easier.
- The following table lists the PHP functions that can be used with the MySQL server for added functionality in your PHP script.
Some of the more commonly used functions are:
❑ mysql_connect
("hostname", "user", "pass"): Connects to the MySQL server.
❑ mysql_select_db("database name"): Equivalent to the MySQL command USE; makes the selected database the active one.
❑ mysql_query("query"): Used
to send any type of MySQL command to the server.
❑ mysql_fetch_rows("results variable from query"): Used to return a row of the entire results of a database query.
❑ mysql_fetch_array("results variable from query"): Used to return several rows of the entire results of a database query.
❑ mysql_error(): This shows the error message that has been returned directly from the MySQL server.
Example:-
$query = “SELECT * from TABLE”;
$results
= mysql_query($query);
or
$results
= mysql_query(“SELECT * from TABLE”);
The
results of the query are put into a temporary array known as $results.
Which show results.
=======================================
0 Comments