I'm currently stuck in a project where I need to pull info from a database and sort it by order of 2 seperate fields and creates a text report of the results. No problems there but now what the boss is wanting to do is break it up into slices of 8 records per file and save each file individually so you get issue3page1.txt is the first 8 results from the query and issue3page2.txt would be result 9-16 of the query. Anything results less than 8 for the final recordset would consitute 1 page as well.
Here's what Im using now.
well i would rebuild this structure in your code:
<your code for every record>if ($row = mysql_fetch_array($result)) { do {
to:} while($row = mysql_fetch_array($result)); }
$recordcounter=1;
if (($recordcounter%8)==0) { fclose($fp);while($row = mysql_fetch_array($result)); {$recordcounter++;
$filename='issue3page'.(1+intval($recordcounter/8)) .'.txt';
$fp=fopen($filepath.'/'.$filename,'w+');//or whatever you had working
}
<your code for every record>
}
this is NOT tested so try to understand what i want to do:
if (!($recordcounter%8)): whenever $recordcounter is dividible by 8, $recordcounter%8 is 0, because there are no "remains".
intval($recordcounter/8): 1 when $recordcounter=8
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php