データを JSON から CSV 形式に変換すると、CSV ファイルで以下のような出力が得られます。可能な提案はありますか?
0,"","","0","0","0","0","","","0","0","","","","0","0","0","0","0","0","","","","","","0","0","0","0","","0","","","0","0","0","","0","0","0","0","0","0","0","","","","","","","","","","","","","","","","","","","","","","","","","","","0","0","","","","","","","","0","0",","",""
私の機能
function csv($form){
$fp = fopen($form, "w");
$sql = "SELECT * FROM log AS jon
LEFT JOIN r as rec ON jon.num=rec.num
LEFT JOIN b as bio ON jon.num=bio.num
LEFT JOIN p as po ON jon.num=po.num
LEFT JOIN re as recur ON jon.num=recur.num
LEFT JOIN s as spir ON jon.num=spir.num
LEFT JOIN te as ten ON jon.num=ten.num
LEFT JOIN tt as ttai ON jon.num=ttai.num
LEFT JOIN vi as vis ON jon.num=vis.num
LEFT JOIN ac as acui ON jon.num=acui.num
LEFT JOIN au as aud ON jon.num=aud.num
LEFT JOIN e as ec ON jon.num=ec.num
LEFT JOIN ha as han ON jon.num=han.num
LEFT JOIN pe as peri ON jon.num=peri.num
LEFT JOIN pr as pre ON jon.num=pre.num";
$res=mysql_query($sql);
if(!$res) die ('Unable to run query:'.mysql_error());
while ($row = mysql_fetch_assoc($res))
{
//echo implode(', ', $row)."\r\n";
fputcsv(STDOUT, $row);
}
PHPファイル内
$rslt = mysql_query("SELECT * FROM ".$table." WHERE num = ".$id."") or die("Unable to Execute QueryThe error was" . mysql_error());
$record = mysql_fetch_assoc($rslt);
var jsonObject = JSON.stringify($record);