Convert ke xl dan word

Sutio Bangkit · Aug 13, 2012
Gini Mr.Ellyx Christian,saya mau buat data bsa di convert ke xl sm word...beberapa page saya sdh bisa,cuman yang satu ini ga bisa2,,selalu error..errornya kyk gini..
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\sutio\admin\tampil_pendaftar.php:9) in C:\Program Files\xampp\htdocs\sutio\admin\tampil_pendaftar.php on line 163

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\sutio\admin\tampil_pendaftar.php:9) in C:\Program Files\xampp\htdocs\sutio\admin\tampil_pendaftar.php on line 164

ini scriptnya...tolong dikroscek ya Mr.Ellyx
than'x
<?
include "../konek.php";
include "session.php";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Halaman admin</title>
<link rel="stylesheet" href="../styles/layout.css" type="text/css" />
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>


</head>
<body>
<!--#############################################################-->
<? include "header_admin.php"  ?>
<!--#############################################################-->
<? include "sidekiri.php"  ?>


<?php
$siswa->Export = @$_GET["export"]; // Get export parameter
$sExport = $siswa->Export; // Get export parameter, used in header
$sExportFile = $siswa->TableVar; // Get export file, used in header
//$siswa=
$sExportFile1=pendaftar;
?>
<?php
if ($siswa->Export == "excel") {
	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: attachment; filename=' . $sExportFile1 .'.xls');
}
if ($siswa->Export == "word") {
	header('Content-Type: application/vnd.ms-word');
	header('Content-Disposition: attachment; filename=' . $sExportFile1 .'.doc');
}
?>
<?php if ($siswa->Export == "") { ?>

<table>
<tr><td align="center" valign="middle"><a href="tampil_pendaftar2.php?export=excel">Export Data Murid ke Mcr.Excel</a></td>
<td><a href="tampil_pendaftar2.php?export=excel"><img src="images/xl.png" width="30"  height="35" border="0"/></a></td>
<td width="10%"></td>
<td><a href="tampil_pendaftar2.php?export=word">Export Data Murid ke Mcr.Word</a></td>
<td><a href="tampil_pendaftar2.php?export=word"><img src="images/word.png"  width="30" height="35" border="0"/></a></td>
</tr>
</table>
<?php } ?>

<table width="65%" style="font-size:10px; color:#000000;">
<tr>
	<td>No</td>
	<td>Nama</td>
	<td>T.Lahir</td>
	<td>Tgl Lahir</td>
	<td>JK</td>
	<td>Agama</td>
	<td>Alamat</td>
	<td>Telfon</td>
	<td>Email</td>
	<td>Action</td>
</tr>
<? 
include "../konek.php";

$no=1;	
$query="select * from daftar_siswa order by id";
$sql=mysql_query($query);
while ($row=mysql_fetch_array($sql))	{
$id=stripslashes($row['id']);
$nama=stripslashes($row['nama']);
$t_lahir=stripslashes($row['tempat_lahir']);
$tgllahir=stripslashes($row['tanggal_lahir']);
$jk=($row==0) ? "Laki-Laki" : "Perempuan" ;
$agama=stripslashes($row['agama']);
$telp=stripslashes($row['telp']);
$alamat=stripslashes($row['alamat']);
$email=stripslashes($row['email']);
$warna=($no%2==1)?"#F9F9F9":"#FFF0F0";
?>
<tr bgcolor="<?=$warna?>">
	<td><?=$no?></td>
	<td><?=$nama?></td>
	<td><?=$t_lahir?></td>
	<td><?=$tgllahir?></td>
	<td><?=$jk?></td>
	<td><?=$agama?></td>
	<td><?=$alamat?></td>
	<td><?=$telp?></td>
	<td><?=$email?></td>
	<td><a href="delete_pendaftar.php?id=<?=$id?>">Delete</a> </td>
</tr>
<? $no++;  }	?>
</table>
</div>

<div style="clear:both">  <? include '../footer.php' ; ?></div>
</body>
</html>
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Aug 13, 2012 · 0 Suka · 0 Tidak Suka
itu karena kamu memanggil fungsi header setelah ada output (html tag). fungsi header harus dipanggil sebelum ada output.
0
Loading...
Sutio Bangkit · Aug 13, 2012 · 0 Suka · 0 Tidak Suka
Kurang ngerti pak..gini aja deh ga..ane penya skrip 2 (skrip1 $ skrip2)knapa yang skrip1 bisa dan skrip2 ga bisa di eksport ke xl maupun word....padal menurut ane ga ada perbedaan yg berarti....
maaf klu salah..(msh belajar)..
<!---Script1--------tampil_pendaftar2.php---->
<?
include "../konek.php";

?>
<?php
$siswa->Export = @$_GET["export"]; // Get export parameter
$sExport = $siswa->Export; // Get export parameter, used in header
$sExportFile = $siswa->TableVar; // Get export file, used in header
//$siswa=
$sExportFile1=kelas2a;
?>
<?php
if ($siswa->Export == "excel") {
	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: attachment; filename=' . $sExportFile1 .'.xls');
}
if ($siswa->Export == "word") {
	header('Content-Type: application/vnd.ms-word');
	header('Content-Disposition: attachment; filename=' . $sExportFile1 .'.doc');
}
?>
<?php if ($siswa->Export == "") { ?>

<table>
<tr><td align="center" valign="middle"><a href="tampil_pendaftar2.php?export=excel">Export Data Murid ke Mcr.Excel</a></td>
<td><a href="tampil_pendaftar2.php?export=excel"><img src="images/xl.png" width="30"  height="35" border="0"/></a></td>
<td width="10%"></td>
<td><a href="tampil_pendaftar2.php?export=word">Export Data Murid ke Mcr.Word</a></td>
<td><a href="tampil_pendaftar2.php?export=word"><img src="images/word.png"  width="30" height="35" border="0"/></a></td>
</tr>
</table>
<?php } ?>
<div id="content">
	<h2 align="center">Data Pendaftar2 </h2>
	<table  id="tabel" width="65%" border="0" >
	<tr><td  bgcolor="#fef0f0" colspan="8"  style="color:#00FF00; font-size:18px;" border="0">
	Disini Untuk Menginput Siswa-->> <a href="admin_kelas.php?page=tambah3c">INPUT BARU</a>
	</td></tr>
	<tr>
	<td>No</td>
	<td>Nama</td>
	<td>T.Lahir</td>
	<td>Tgl Lahir</td>
	<td>JK</td>
	<td>Agama</td>
	<td>Alamat</td>
	<td>Telfon</td>
	<td>Email</td>
	<td>Action</td>
	</tr>
	<?php
$no=1;	
$query="select * from daftar_siswa order by id";
$sql=mysql_query($query);
while ($row=mysql_fetch_array($sql))	{
$id=stripslashes($row['id']);
$nama=stripslashes($row['nama']);
$t_lahir=stripslashes($row['tempat_lahir']);
$tgllahir=stripslashes($row['tanggal_lahir']);
$jk=($row==0) ? "Laki-Laki" : "Perempuan" ;
$agama=stripslashes($row['agama']);
$telp=stripslashes($row['telp']);
$alamat=stripslashes($row['alamat']);
$email=stripslashes($row['email']);
$warna=($no%2==1)?"#F9F9F9":"#FFF0F0";
		//
		//tampilkan data pegawai
	?>
<tr bgcolor="<?=$warna?>">
	<td><?=$no?></td>
	<td><?=$nama?></td>
	<td><?=$t_lahir?></td>
	<td><?=$tgllahir?></td>
	<td><?=$jk?></td>
	<td><?=$agama?></td>
	<td><?=$alamat?></td>
	<td><?=$telp?></td>
	<td><?=$email?></td>
	<td><a href="delete_pendaftar.php?id=<?=$id?>">Delete</a> </td>
</tr>
	<? $no++; }?>
	

	</table>
	<br />
</div>

<!----Script2-->
<!--#######################tampil_pendaftar2.php######################################-->
<h4>Pendaftar Calon Siswa SMPS Santo Yoseh</h4>
<?php

?>
<?php
$siswa->Export = @$_GET["export"]; // Get export parameter
$sExport = $siswa->Export; // Get export parameter, used in header
$sExportFile = $siswa->TableVar; // Get export file, used in header
//$siswa=
$sExportFile1=Kelas2a;
?>
<?php
if ($siswa->Export == "excel") {
	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: attachment; filename='.$sExportFile1.'.xls');
}
if ($siswa->Export == "word") {
	header('Content-Type: application/vnd.ms-word');
	header('Content-Disposition: attachment; filename=' . $sExportFile1 .'.doc');
}
?>
<?php if ($siswa->Export == "") { ?>
<table>
<tr><td align="center" valign="middle"><a href="tampil_pendaftar2.php?export=excel">Export Data Murid ke Mcr.Excel</a></td>
<td><a href="tampil_pendaftar2.php?export=excel"><img src="images/xl.png" width="30"  height="35" border="0"/></a></td>
<td width="10%"></td>
<td><a href="tampil_pendaftar2.php?export=word">Export Data Murid ke Mcr.Word</a></td>
<td><a href="tampil_pendaftar2.php?export=word"><img src="images/word.png"  width="30" height="35" border="0"/></a></td>
</tr>
</table>
<?php } ?>

<div class="admin">
<table width="65%" style="font-size:10px; color:#000000;">
<tr>
	<td>No</td>
	<td>Nama</td>
	<td>T.Lahir</td>
	<td>Tgl Lahir</td>
	<td>JK</td>
	<td>Agama</td>
	<td>Alamat</td>
	<td>Telfon</td>
	<td>Email</td>
	<td>Action</td>
</tr>
<? 
include "../konek.php";

$no=1;	
$query="select * from daftar_siswa order by id";
$sql=mysql_query($query);
while ($row=mysql_fetch_array($sql))	{
$id=stripslashes($row['id']);
$nama=stripslashes($row['nama']);
$t_lahir=stripslashes($row['tempat_lahir']);
$tgllahir=stripslashes($row['tanggal_lahir']);
$jk=($row==0) ? "Laki-Laki" : "Perempuan" ;
$agama=stripslashes($row['agama']);
$telp=stripslashes($row['telp']);
$alamat=stripslashes($row['alamat']);
$email=stripslashes($row['email']);
$warna=($no%2==1)?"#F9F9F9":"#FFF0F0";
?>
<tr bgcolor="<?=$warna?>">
	<td><?=$no?></td>
	<td><?=$nama?></td>
	<td><?=$t_lahir?></td>
	<td><?=$tgllahir?></td>
	<td><?=$jk?></td>
	<td><?=$agama?></td>
	<td><?=$alamat?></td>
	<td><?=$telp?></td>
	<td><?=$email?></td>
	<td><a href="delete_pendaftar.php?id=<?=$id?>">Delete</a></td>
</tr>
<? $no++;  }	?>
</table>
</div>


0
Loading...
Ellyx Christian · Aug 14, 2012 · 0 Suka · 0 Tidak Suka
itu namanya jelas ada perbedaan, di script 1 tidak ada output sebelum fungsi header dipanggil. Sedangkan di script 2 ada output berupa
Quote:
<!----Script2-->
<!--#######################tampil_pendaftar2.php######################################-->
<h4>Pendaftar Calon Siswa SMPS Santo Yoseh</h4>
sebelum di fungsi header dipanggil.
Hilangkan
Quote:
<!----Script2-->
<!--#######################tampil_pendaftar2.php######################################-->
<h4>Pendaftar Calon Siswa SMPS Santo Yoseh</h4>
maka itu akan berfungsi
0
Loading...
Sutio Bangkit · Aug 14, 2012 · 0 Suka · 0 Tidak Suka
Berarti pengaruh walau hanya 1 baris aja..oklah mas Ellyx..Thn'x Banget