I have been dealing with this all day ... I am doing a SQL Query and it suppose to return several rows, but I am only getting one, I would believe it is the first one, I want to save these results/rows in a CSV file.
So when I do the var_dump only one result is showing and I can only write that first line in the CSV file.
session_start();
$file = 'file.csv';
if(isset($_POST['button1'])){
echo("You clicked button one!");
$con=mysqli_connect("localhost","root","","test");
$query = "SELECT * FROM test.tec_milenio_cubo";
$result = mysqli_query($con, $query); // EJECUTAS LA CONSULTA
$row = mysqli_fetch_assoc($result);
var_dump ($row);
$_SESSION['file'] = $file;
$fp = fopen($file, 'w');
foreach ($row as $value) {
fputcsv($fp, $value);
}
fclose($fp);
mysqli_close($con);