hi am new for php.. am trying a download a csv file.. i need to create a new file after every 50 records..
0.062201000014461.0002771700.
0.062201000014480.0000000000.
0.062201000014723.0005133400.
0.062201000015828.0005848000.
0.062201000015927.0003018200.
this is the sample output. i need to split the output file so the each file should contain 50 records.

<?php
include("conn.inc");
$aca=$_REQUEST['aca'];
$mon=$_REQUEST['mon'];
header('Content-Type: text/csv; charset=utf-8');
header("Pragma: no-cache");
header("Expires: 0");

$output = fopen('php://output', 'w');
$str="select staffsal.iobno,monsal.* from staffsal,monsal where staffsal.refno=monsal.refno and monsal.monyr='".$mon."' and acadyr='".$aca."' order by staffsal.iobno";
$rows = mysql_query($str);
$i=0;
$msg="";
while ($row = mysql_fetch_array($rows))
{
$np=$row['net']; // net salary
$ro[]=$row['iobno'];// bank account no
$dd= str_pad(round($np,0),8,"0",STR_PAD_LEFT);
$dd=$dd."00";
$ro[]=$dd;
$i++;
$msg.="0.$ro[0].$ro[1].\r\n";
if (($i%50)==0)
{
header("Content-Disposition: attachment; filename=$mon.$i.csv");
echo $msg;
$msg="";
}
unset($ro); 
}
?>

thanks in advance

You can use LIMIT in your query, but you won't be able to download more than a single file at once.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.