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 Detials

Q.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:

  1. mysqli_fetch_row() - Get a result row as an enumerated array
  2. mysqli_fetch_array() - Fetch a result row as an associative array, a numeric array, or both
  3. mysqli_fetch_object() - Fetch a result row as an object
  4. mysqli_fetch_assoc() - Fetch a result row as an associative array
View Detials

Q.3. What are the different storage engine present in MySQL?

Ans.:

There are 5 different types of storage engine present in MySql.

  1. MyISAM
  2. Heap
  3. Merge
  4. INNO DB
  5. 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