Database data export is a familiar operation for many of us. phpMyAdmin is the go to choice for a database client in PHP. It provides database administration tools and also allows exporting the data. The exported data can be in various formats like SQL, CSV as selected. Please let me know if below code is useful. I used it for adding same functionality on my website here.
connect_error) {
die("Connection failed: " . $conn->connect\_error);
}
$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "
" . $conn->error;
}
$conn->close();
?>
Here is another good reference https://phppot.com/php/database-data-export-to-excel-file-using-php/