<!DOCTYPE html>
<html>
<link rel="shortcut icon" href="idea.png">    
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Export Data Ke Excel</title>
</head>
<body>
    <link rel="shortcut icon" href="idea.png">
	<style type="text/css">
	body{
		font-family: sans-serif;
	}
	table{
		margin: 20px auto;
		border-collapse: collapse;
	}
	table th,
	table td{
		border: 1px solid #3c3c3c;
		padding: 3px 8px;

	}
	a{
		background: blue;
		color: #fff;
		padding: 8px 10px;
		text-decoration: none;
		border-radius: 2px;
	}
	</style>

	<center>
		<h1>Data Student</h1>
	</center>

	<center>
		<a target="_blank" href="export_excel.php">EXPORT KE EXCEL</a>
	</center>

	<table>
		<tr>
		        
	
	
	            <th>No.</th>
                <th>Nama</th>
                <th>Kelas</th>
                <th>Gender</th>
                <th>Tgl Lahir</th>
                <th>Alamat Tinggal</th>
		        <th>Testimoni</th>
		
				
			</tr>
		<?php 
	     	error_reporting(E_ALL);
           date_default_timezone_set('Asia/Jakarta');
	
	  	session_start();
		
		
			$logkanwil=$_SESSION["logkanwil"]; 
		
   //if(!isset($_SESSION["login"]) ) {
//	   header("Location: ../login.php");
//	 exit;
  //  }	
		
	

   //if(isset($_SESSION["login"]) && ($_SESSION["kanwil"] <>"KP") ) {
    // 	header("Location: ../login.php");
   	//exit;
  // }

		
		
		// koneksi database
	//	$koneksi = mysqli_connect("localhost", "u1665228", 'niaga1234', "u1665228_student");
		$koneksi = mysqli_connect("localhost", "jbkzbmma", 'o7B-a54CP7fp#G', "jbkzbmma_student");


		//$koneksi = mysqli_connect("localhost","root","","pegawai");

		// menampilkan data pegawai
		
		
    if($logkanwil=="KP")
				{
	    $data = mysqli_query($koneksi,"select * from data_student order by nama");
     			}
				else{
	  	$data = mysqli_query($koneksi,"select * from data_student order by nama");		
      			}
		
		
		
		
		$no = 1;
		while($d = mysqli_fetch_array($data)){
		?>
		<tr>
			 <td><?php echo $no++; ?></td>
			<td><?php echo $d['nama']; ?></td>
			<td><?php echo $d['kelas']; ?></td>
			<td><?php echo $d['jk']; ?></td>
			<td><?php echo date("d-m-Y", strtotime($d['tgl_lahir']));?></td>
			
			<td><?php echo $d['alamat']; ?></td>
	        <td><?php echo $d['testimoni']; ?></td>

			
		</tr>
		<?php 
		}
		?>
	</table>
</body>
</html>