I'm trying to save into file a mysql SELECT query as follows:
$result = mysqli_query($db,$sql);
$out = fopen('tmp/csv.csv', 'w');
while ($row = $result -> fetch_row()) {
fputcsv($out,$row);
}
fclose($out);
after save I need to publish on a page as follows :
while ($row = mysqli_fetch_assoc($result)) {
//embed html code
}
The problem is that anytime I run $result->fetch_row(), a record of data is lost. I need to be able to run fetch_object at least 2 times within my code and preserve the data. I thought cloning would be a good solution for this, but it isn't.
Any hints, other that doing 2 query on the sql database ?