Tell me how to execute an sql query? How to fetch its result?



Tell me how to execute an sql query? How to fetch its result?..

Answer / Sanjeev Aherwar

"To execute an SQL query, you can use PHP's MySQL extension. Here is an example: nn$db = new mysqli("localhost", "username", "password", "database");nif ($db->connect_error) {n die("Connection failed: " . $db->connect_error);n}nn$sql = "SELECT * FROM table";n$result = $db->query($sql);nnWhile ($row = $result->fetch_assoc()) {n echo $row['columnName'];n}""

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

Why do we use interface in php?

1 Answers  


Explain about objects in PHP?

1 Answers  


Does mysql need php?

1 Answers  


What is the difference between $message and $$message in php?

1 Answers  


Is it possible to submit a form with a dedicated button?

1 Answers  


How to create connection in php?

1 Answers  


what is the url rewriting?how to rewrite the url? give any example

1 Answers  


in PHP for pdf which library used?

1 Answers  


coding for deleting items form data base on select

1 Answers  


How to turn on the session support?

1 Answers  


What is the difference between htmlentities() and htmlspecialchars()?

0 Answers  


Is php worth learning in 2019?

1 Answers  


Categories