How can i show to export button in csv file. Download Simple Export CSV file in PHP .
Problem : file can not show only data printed on page. What’s the problem with the code? i can not understand.enter image description here
function car_data_callback()
// {
// //Database connections
// $database_server = "";
// $database_username = "";
// $database_password = "";
// $database_name = "";
// // Create database connection
// $connection = mysqli_connect($database_server, $database_username, $database_password, $database_name);
// // Check connection
// if($connection === false)
// {
// die("ERROR: Could not connect. " . mysqli_connect_error());
// }
// $query = "SELECT * FROM wpsn_car_price_table";
// $result = mysqli_query($connection, $query);
// $number_of_fields = mysqli_num_fields($result);
// $headers = array();
// for ($i = 0; $i < $number_of_fields; $i++)
// {
// $headers[] = mysqli_field_name($result , $i);
// }
// $fp = fopen('php://output', 'w');
// if ($fp && $result) {
// header('Content-Type: text/csv');
// header('Content-Disposition: attachment; filename="export.csv"');
// header('Pragma: no-cache');
// header('Expires: 0');
// fputcsv($fp, $headers);
// while ($row = $result->fetch_array(MYSQLI_NUM)) {
// fputcsv($fp, array_values($row));
// }
// die;
// }
// }
// function mysqli_field_name($result, $field_offset)
// {
// $properties = mysqli_fetch_field_direct($result, $field_offset);
// return is_object($properties) ? $properties->name : null;
// }