PHP SQL Select
PHP SQL Select is used to execute mysql select query in the php application. The PHP SQL Select uses mysql_select_db () function that set the active MySQL database. The function returns true on successful connection, or False on failure of connection. To perform SQL Select query in PHP, we must create a database connection between the PHP and MySQL.
Understand with Example
This example illustrates how to execute mysql select query in the php application. In the previous example we have already execute many more select query for retrieving data from database but in this example we show the use of mysql_select_db function in php application. The sql_select.php starts with <? php and end with />. The <?php enclosed the con variable assigned the value of mysql_connect () function that accept the local host, user and pass. The die () script part will be executed in case of connection failure corresponding to specific print message on browser. The mysql_select_db () function accept parameter database and connection.
database : This is used to specifies the name of database to be select.
connection : This specifies the MySQL connection. If it is not specified, the last connection opened by mysql_connect () is used.
Source Code of sql_select.php
<?php
|
Output: