I have 13640 users and I'm 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 counter 1000. So 13 files remain instead of 14, the last one that is not created would not store 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 variable $ excel takes care of a class to create these files each time the loop happens but does not create the last file because it does not reach 1000 registers but 640. How could you edit this code to get the desired result? / p>