<form>
<p><a href="print_laporan_perusahaan.php"><input type="button" name="tambah" value="Cetak laporan" class="formbutton"> </input></a>  
<a href="cetak_excel_laporan_perusahaan.php"><input type="button" name="tambah" value="Cetak ke Excel" class="formbutton"></p>  
</form>
<?php
		echo"
		<table>
		<tr>
		<th>No</th>
		<th>Tanggal Registrasi</th>
		<th>ID Perusahaan</th>
		<th>Nama perusahaan</th>
		<th>Alamat</th>
		<th>Telp</th>
		<th>fax</th>
		<th>email</th>
		<th>aksi</th>
		</tr>";
$tampil="SELECT * from perusahaan ORDER BY id_perusahaan";
$hasil=mysql_query($tampil);
$no=1;
while ($data=mysql_fetch_array($hasil))
{
	echo"<tr>
		<td>$no</td>
		<td>$data[tanggal]</td>
		<td>$data[id_perusahaan]</td>
		<td>$data[nama_perusahaan]</td>
		<td>$data[alamat]</td>
		<td>$data[telp]</td>
		<td>$data[fax]</td>
		<td>$data[email]</td>
		<td><a href='edit_perusahaan.php?id=$data[id_perusahaan]'><img src='images/edit-icon.png' width='20' height='20' border='1' /></a><a href='aksi_perusahaan.php?module=user&act=hapus&id=$data[id_perusahaan]'><img src='images/delete-icon.png' width='20' height='20' border='1' /></a></td>
		</tr>";
		$no++;
		
}
echo"</table>";
?>    <form>
<p><a href="print_laporan_perusahaan.php"><input type="button" name="tambah" value="Cetak laporan" class="formbutton"> </input></a>  
<a href="cetak_excel_laporan_perusahaan.php"><input type="button" name="tambah" value="Cetak ke Excel" class="formbutton"></p>  
</form>
 <form method="get" action="">
 Berdasarkan
 <select name="kolom">
 <option value="nama_perusahaan">nama perusahaan</option>
  <option value="alamat">Alamat</option>
   <option value="email">Email</option>
   <!-- tambahkan yang lainnya --->
 </select>
 Keyword <input type="text" name="q"/>
 <input type="submit" name="search" value="Search"/>
 </form>
<?php
		echo"
		<table>
		<tr>
		<th>No</th>
		<th>Tanggal Registrasi</th>
		<th>ID Perusahaan</th>
		<th>Nama perusahaan</th>
		<th>Alamat</th>
		<th>Telp</th>
		<th>fax</th>
		<th>email</th>
		<th>aksi</th>
		</tr>";
if(isset($_GET['search']){
	$tampil="SELECT * from perusahaan where ".$_GET['kolom']." like '%".$_GET['q']."%' ORDER BY id_perusahaan";
}else{
	$tampil="SELECT * from perusahaan ORDER BY id_perusahaan";
}
$hasil=mysql_query($tampil);
$no=1;
while ($data=mysql_fetch_array($hasil))
{
	echo"<tr>
		<td>$no</td>
		<td>$data[tanggal]</td>
		<td>$data[id_perusahaan]</td>
		<td>$data[nama_perusahaan]</td>
		<td>$data[alamat]</td>
		<td>$data[telp]</td>
		<td>$data[fax]</td>
		<td>$data[email]</td>
		<td><a href='edit_perusahaan.php?id=$data[id_perusahaan]'><img src='images/edit-icon.png' width='20' height='20' border='1' /></a><a href='aksi_perusahaan.php?module=user&act=hapus&id=$data[id_perusahaan]'><img src='images/delete-icon.png' width='20' height='20' border='1' /></a></td>
		</tr>";
		$no++;
 
}
echo"</table>";
?>Tutorial ada di http://www.myphptutorials.com/tutorials/40/membuat-searching-skrip-pencarian-data                <?php
if( mysql_connect("localhost","root","") ){
mysql_select_db("dorm");
}
 
 
$title = "Laporan Data Perusahaan";
$content_header = "<table border=1><tr>
		<th>No</th>
		<th>Tanggal Registrasi</th>
		<th>ID Perusahaan</th>
		<th>Nama perusahaan</th>
		<th>Alamat</th>
		<th>Telp</th>
		<th>Fax</th>
		<th>Email</th>
		</tr>";
$content_footer = "</table>";
$content_dalam = "";
 
 
$sql = "SELECT * FROM `perusahaan`";
$q   = mysql_query( $sql );
$no=1;
while( $r=mysql_fetch_array( $q ) ){
 
$data = "<tr><td>".$no."</td><td>".$r['tanggal']."</td><td>".$r['id_perusahaan']."</td><td>".$r['nama_perusahaan']."</td><td>".$r['alamat']."</td><td>".$r['telp']."</td><td>".$r['fax']."</td><td>".$r['email']."</td></tr>";
$content_dalam = $content_dalam ."\n". $data;
$no++;
}
 
$content_sheet = $title . "\n" . $content_header . "\n" . $content_dalam . "\n" . $content_footer;
 
 
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
print $content_sheet;
?>
                 //kode sebelumnya......
if(isset($_GET['q']) && isset($_GET['kolom'])){
	$sql = "SELECT * FROM `perusahaan` WHERE `".$_GET['kolom']."` like '%".$_GET['q']."%'";
}else{
	$sql = "SELECT * FROM `perusahaan`";
}
//kode selanjunya......                    <form>
    <p><a href="print_laporan_perusahaan.php"><input type="button" name="tambah" value="Cetak laporan" class="formbutton"> </input></a>  
    <a href="cetak_excel_laporan_perusahaan.php"><input type="button" name="tambah" value="Cetak ke Excel" class="formbutton"></p>  
    </form>
    <form method="get" action="">
    dari tanggal <input type="text" name="q"/>    
    S/D <input type="text" name="q"/>
    <input type="submit" name="search" value="Search"/>
    </form>
    <?php
    echo"
    <table>
    <tr>
    <th>No</th>
    <th>Tanggal Registrasi</th>
    <th>ID Perusahaan</th>
    <th>Nama perusahaan</th>
    <th>Alamat</th>
    <th>Telp</th>
    <th>fax</th>
    <th>email</th>
    <th>aksi</th>
    </tr>";
    if(isset($_GET['search']){
    $tampil="SELECT * from perusahaan where ".$_GET['kolom']." like '%".$_GET['q']."%' ORDER BY id_perusahaan";
    }else{
    $tampil="SELECT * from perusahaan ORDER BY id_perusahaan";
    }
    $hasil=mysql_query($tampil);
    $no=1;
    while ($data=mysql_fetch_array($hasil))
    {
    echo"<tr>
    <td>$no</td>
    <td>$data[tanggal]</td>
    <td>$data[id_perusahaan]</td>
    <td>$data[nama_perusahaan]</td>
    <td>$data[alamat]</td>
    <td>$data[telp]</td>
    <td>$data[fax]</td>
    <td>$data[email]</td>
    <td><a href='edit_perusahaan.php?id=$data[id_perusahaan]'><img src='images/edit-icon.png' width='20' height='20' border='1' /></a><a href='aksi_perusahaan.php?module=user&act=hapus&id=$data[id_perusahaan]'><img src='images/delete-icon.png' width='20' height='20' border='1' /></a></td>
    </tr>";
    $no++;
     
    }
    echo"</table>";
    ?>