PHP uses following functions to fetch data from an existing MySQL table −
mysql_query() function
This function is used in PHP script to fetch data from an existing MySQL table. This function takes two parameters and returns TRUE on success or FALSE on failure. Its syntax is as follows −
Syntax
bool mysql_query( sql, connection );
Followings are the parameters used in this function −
S. No. | Parameter & Description |
---|---|
1. | Sql Required - SQL query to fetch data from an existing MySQL table |
2. | connection Optional - if not specified, then the last opened connection by mysql_connect will be used. |
mysql_fetch_array() function
This is another function which is used in PHP script while fetching the data from an existing MySQL. This function returns the row as an associative array, a numeric array, or both. This function returns FALSE if there are no more rows. The syntax of using mysql_fetch_array() function is as follows −
Syntax
mysql_fetch_array(result, resulttype);
Followings are the parameters used in this function −
S. No. | Parameter & Description1 |
---|---|
1. | Result Required- Specifies a result set identifier returned by mysql_query(), mysql_store_result() or mysql_use_result() |
2. | Resulttype Optional - Specifies what type of array that should be produced. Can be one of the following values −
|