

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Which PHP functions are used in the PHP script to fetch data from an existing MySQL table?
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 −
|
- Related Questions & Answers
- Which PHP function is used to insert data into an existing MySQL table?
- How to write PHP script to delete data from an existing MySQL table?
- Which PHP function is used to delete an existing MySQL table?
- How to write PHP script to update an existing MySQL table?
- How to write PHP script to fetch data, based on some conditions, from MySQL table?
- How can we insert data into an existing MySQL table by using PHP script?
- Which PHP function is used to delete an existing database?
- How can we delete an existing MySQL table by using PHP script?
- Which PHP function is used to establish MySQL database connection using PHP script?
- Which PHP function is used to create a MySQL table?
- How can we fetch all the data from MySQL table by using mysql_fetch_array() function, returning an array with the numeric index, in PHP script?
- Which PHP function is used to disconnect from MySQL database connection?
- How to write PHP script by using LIKE clause inside it to match the data from MySQL table?
- Which PHP function is used to select a MySQL database?
- How can we display all the records from MySQL table with the help of PHP script?
Advertisements