Top 5 PHP-MySQL Interview Questions and Answers
Here, you will come across some of the most frequently asked questions in PHP-MySQL job interviews which will help you in your interview preparation.
Let's have a look at some of the most popular and significant PHP-MySQL questions and answers:
Interview Questions
Most Essential And Frequently Asked Interview
Questions And Answer
PHP-MySQL
Q.1. How we can find last insert id in table?
Ans.:MySQL | Find last insert id in the table
By using the MySQL function mysqli_insert_id() we can retrieve the last inserted id in the database table.
View DetialsQ.2. how many ways we can retrieve the data in the result set of MySQL using PHP?
Ans.:PHP-MYSQL | Fetch Recoards From MySql table
There are 4 ways:
- mysqli_fetch_row() - Get a result row as an enumerated array
- mysqli_fetch_array() - Fetch a result row as an associative array, a numeric array, or both
- mysqli_fetch_object() - Fetch a result row as an object
- mysqli_fetch_assoc() - Fetch a result row as an associative array
Q.3. What are the different storage engine present in MySQL?
Ans.:There are 5 different types of storage engine present in MySql.
- MyISAM
- Heap
- Merge
- INNO DB
- ISAM
MyISAM is the default storage engine for MySQL
Q.4. How can we find the number of rows in a result set using PHP?
Ans.:PHP | Find the number of rows in a result set
Bellow code is use for the same
$sql = "SELECT * FROM table1";
$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo $num_rows;
Q.5. What are the difference between mysqli_fetch_assoc and mysqli_fetch_array?
Ans.:PHP-MYSQL | mysqli_fetch_assoc() VS mysqli_fetch_array()
mysqli_fetch_assoc() function fetch a result row as an associative array where as mysqli_fetch_array() function fetch a result row as an associative array, a numeric array, or both.
View Detials