0

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

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by pritaeas
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.