// Replace parameters with your own connection details $servername = "localhost"; $username = "your_username"; $password = "your_password"; $dbname = "your_database"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); }
$table_name = "users"; // Select all data from the "users" table $sql = "SELECT * FROM $table_name"; $result = mysqli_query($conn, $sql); // Output the results while ($row = mysqli_fetch_assoc($result)) { echo $row["name"] . ", " . $row["email"] . "These examples use the mysqli package, which is a PHP extension for connecting to MySQL databases.
"; }