Connecting MySQL with PHP

Published July 26, 2025 By Sai Sree Ram Gundepudi

PHP Example (MySQLi)

$conn = new mysqli('localhost', 'user', 'pass', 'employees');
$result = $conn->query("SELECT * FROM employees");
while($row = $result->fetch_assoc()) {
  echo $row['name'];
}

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article