1
I have 13640 users and I am creating 1 email capture file for every 1000 users. With the code I have, it generates 13 files and has a surplus of 640 users that are left behind because it did not reach 1000 counter. So are 13 files instead of 14, the last that is not created would save not 1000, plus the rest (640).
The code I’m using to create the files inside the folder is this:
// Instrução até chegar na quantidade final de registros
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$contador++;
if($contador == 1000){
$excel = new ExcelWriter("listas/report".rand(10000, 99999).".xls");
$contador = 0;
}
}
The $excel variable takes over a class to create these files each time the loop happens but does not create the last file because it does not reach 1000 records but 640. How could you edit this code to get the desired result?