此代码中的错误,用于将其导出为excel。如果没有使用第1行和第2行代码是完美的。如果使用第1行和第2行代码它正在工作但don't export to excel
,则重定向到PHP控制页面。也可以看到它的正常结果。问题在哪里?
$servis_listesi = mysql_query("SELECT * from servis_listesi");
while($tumservisler = mysql_fetch_array($servis_listesi)){
$ad_servis = $tumservisler["servis_adi"];
$kod_servis = $tumservisler["servis_kodu"];
$servisil = $tumservisler["servis_il"]; // line 1
$servisilce = $tumservisler["servis_ilce"]; // line 2
$ortalamasi = mysql_query("select avg(anket_puani),COUNT(anket_puani) from anket_sonuclar where servis_kodu='".$kod_servis."' and anket_tarihi between '".$tarih1."' and '".$tarih2."'");
$bicimle = mysql_fetch_array($ortalamasi);
$sonuc_reel = $bicimle["avg(anket_puani)"];
$sonuc_sayi = $bicimle["COUNT(anket_puani)"];
$sonuc_net = round($sonuc_reel,2);
echo '<tr>
<td>'.$kod_servis.'</td>
<td>'.$ad_servis.'</td>
<td>'.$servisil.'</td> <!-- line 1 want to use here-->
<td>'.$servisilce.'</td><!-- line 2 want to use here-->
<td>'.$sonuc_sayi.'</td>
<th></th>
<td>'.$sonuc_net.'</td>
</tr>';
};
header("Content-Type: application/vnd.ms-excel");header('Content-Type: text/html; charset=utf-8');header("Content-disposition: attachment;filename='anket_list ".date('d.m.Y').".xls");
答案 0 :(得分:0)
嗨Mahir如果有可能请尝试下面的代码并检查一次。 $ tumservisler = mysql_fetch_array($ servis_listesi); 而($ tumservisler){
}
答案 1 :(得分:0)
错误已解决。我使用了之前的header
。感谢。