从mysql导出的数据,在excel里自动就换行了 
我想让每一字段的数据放在下一列的单元格里(横着数的),而不是下一行的单元格。
大家能否帮我看下,我的代码哪里有问题。谢谢。<?php
    require_once("db.php");
    $tn = $_POST['TN']?$_POST['TN']:'';
$cn = $_POST['CN']?$_POST['CN']:'';
$ai = $_POST['AI']?$_POST['AI']:'';
$tn2 = $_POST['TN2']?$_POST['TN2']:'';
$cn2 = $_POST['CN2']?$_POST['CN2']:'';
$ai2 = $_POST['AI2']?$_POST['AI2']:'';
$ppe = $_POST['PPE']?$_POST['PPE']:'';
$ppe2 = $_POST['PPE2']?$_POST['PPE2']:'';
$amw  = $_POST['AMW']?$_POST['AMW']:'';
$mmw  = $_POST['MMW']?$_POST['MMW']:'';
$eh = $_POST['EH']?$_POST['EH']:'';
$crops = $_POST['Crops']?$_POST['Crops']:'';
$rei = $_POST['REI']?$_POST['REI']:'';
$crops2 = $_POST['Crop2']?$_POST['Crop2']:'';
$rei2 = $_POST['REI2']?$_POST['REI2']:'';
$pest = $_POST['PEST']?$_POST['PEST']:'';
$rate = $_POST['RATE']?$_POST['RATE']:'';
$note = $_POST['Note']?$_POST['Note']:'';
$restrictions = $_POST['Restrictions']?$_POST['Restrictions']:'';    
        $searchp = "select * from insecticide a LEFT JOIN crop b ON a.ID = b.ID where a.Pestcide_trade_name like'%$tn%' and a.Pestcide_trade_name like'%$tn2%' and b.Crops like'%$crops%' and b.Crops like'%$crops2%' and a.AMW like'%$amw%' and b.Pests like'%$pest%' and a.Company_name like'%$cn%' and a.Company_name like'%$cn2%' and a.Active_ingredient like'%$ai%' and a.Active_ingredient like'%$ai2%' and a.PPE like'%$ppe%' and a.PPE like'%$ppe2%' and a.MMW like'%$mmw%' and a.EH like'%$eh%' and b.REI like'%$rei%' and b.REI like'%$rei2%' ORDER BY a.Pestcide_trade_name ASC";
    $result=mysql_query($searchp)or die(mysql_error());
    $num=mysql_numrows($result);
        mysql_close();
 
    $csv_output = '"Trade name","Company Name","Active Ingredient","PPE","Applicators Must Wear","Mixers Must Wear","Environmental Hazards","CROPS","REI","PEST","RATE","RATE","NOTE","RESTRICTION"';
        

$i=0;
while ($i < $num) {

$tn1 = mysql_result($result,$i,"Pestcide_trade_name");
$cn1 = mysql_result($result,$i,"Company_name");
$ai1 = mysql_result($result,$i,"Active_ingredient");
$ppe1 = mysql_result($result,$i,"PPE");
$amw1 = mysql_result($result,$i,"AMW");
$mmw1 = mysql_result($result,$i,"MMW");

$eh1 = mysql_result($result,$i,"EH");
$crop1 = mysql_result($result,$i,"Crops");
$rei1 = mysql_result($result,$i,"REI");
$pest1 = mysql_result($result,$i,"Pests");
$rate1 = mysql_result($result,$i,"Rate_FL_OZ_ARCE");
$rate11 = mysql_result($result,$i,"RATE_LB_ARCE");
$note1 = mysql_result($result,$i,"Note");
$restrictions1 = mysql_result($result,$i,"Restrictions"); $csv_output .= "$tn1\t$cn1\t$ai1\t$ppe1\t$amw1\t$mmw1\t$eh1\t$crop1\t$rei1\t$pest1\t$rate1\t$rate11\t$note1\t$restrictions1\t\n";
++$i;
}
$filename = "results_".date("Y-m-d_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;?>