$dir="./db/";
$filename="data".date("Ymd").".csv";
$fp = fopen($dir.$filename, "w");
// bank
$result=mysql_query("select * from bank where (BCODE<>'') and ud='' ");
if (mysql_num_rows($result)>0) {
$numfield=mysql_num_fields($result);
for ($i=0;$i<$numfield;$i++) {
if ($i>0) {$comma=",";}else{$comma="";}
$meta = mysql_fetch_field($result);
fwrite($fp, $comma."\"$meta->name\"");
}
fwrite($fp, "\r\n");
for ($i=1;$i<=mysql_num_rows($result);$i++){
$row=mysql_fetch_array($result, MYSQL_NUM);
for ($j=0;$j<$numfield;$j++) {
if ($j>0) {$comma=",";}else{$comma="";}
fwrite($fp, $comma."\"".$row[$j]."\"");
}
fwrite($fp, "\r\n");
}
}
mysql_free_result($result);