Just put an if loop beneath your for loops:
FOR($j=0; $j<mysql_num_fields($result);$j++)
{
if($j<20){
...rest of code
stormdrain
2010-03-31 13:34:04
Just put an if loop beneath your for loops:
FOR($j=0; $j<mysql_num_fields($result);$j++)
{
if($j<20){
...rest of code
If I'm reading that horrid blob of junk correctly, you're simply dumping your database out as comma-seperated values (.csv) text, and forcing it to load in different Office programs by setting MIME headers.
You're not actually creating a .doc or a .xls file, you're generating .csv file. The fact that you're tricking Office into loading the data into Word of Excel doesn't change that fact. CSV data has no formatting whatsoever. There's no page breaks, no fonts, no headers, no footers, no way to specify how many lines on a page, nothing. There's just data: data fields seperated by commas, each line representing a record.