<?php require_once('koneksi/koneksi.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=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include ('header.php') ?>
<div id="isi">
<div align="center"></div>
<fieldset style="width:270px">
<legend><b>Form Pencarian</b></legend>
<form action="show_siswa.php?page=1" method="POST">
<table>
<tr>
<td width="90"><input type="radio" name="field" value="no_induk" />No Induk </td>
<td><input type="radio" name="field" value="nm_siswa" checked="checked" />Nama </td>
</tr>
<tr>
<td colspan="2"><input type="text" name="value" /> <input type="submit" value="cari" /> </td>
</tr>
</table>
</form>
</fieldset>
<form action="show_siswa.php?page=1" method="post">
<input type="submit" value="reset" />
</form>
<center>
<h1>DATA SISWA</h1>
</center>
<a href="input_siswa.php">+Tambah</a>
<table border="1" cellpadding="3" cellspacing="0"><th>No</th><th>No Induk</a></th><th>Nama</a></th><th>Tempat</th><th>Tanggal Lahir</th><th>Jenis Kelamin</th><th>Pendidikan</th><th>Alamat</th><th>No telepon</th><th>Hasil Seleksi</th><th>Aksi</th>
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
//menampung variabel dari parsing
$field=$_POST['field'];
$value=$_POST['value'];
//jika kosong,maka
if(empty($field))
{
$cari=" ";
}
else
{
$cari=" WHERE $field LIKE '$value%'";
}
$warna1= "FFFFFF";
$warna2= "#FFF8DC";
$warna= $warna1;
//jumlah data yg akan ditampilkan
$dataperpage=5;
if($_GET['page'])
{
$nopage=$_GET['page'];
}
else $nopage=1;
// perhitungan offset
$offset=($nopage-1)*$dataperpage;
//query SQL untuk menampilkan data perhalaman sesuai offset
$query = "SELECT * FROM tsiswa $cari order by nm_siswa LIMIT $offset, $dataperpage";
$result= mysql_query($query) or die ('Error');
// membaca nomer halaman
$nopage=$_GET['page'];
// membuat nomer urut awal disetiap halaman berdasarkan formula diatas
$i=$nopage + ($nopage - 1) * ($dataperpage-1);
// menampilkan data
while($data=mysql_fetch_array($result))
{
//background berwarna
if($warna==$warna1){
$warna=$warna2;}
else {$warna=$warna1;}
//memecah tanggal lahir
$tanggal=explode('-',$data['tgl_lhr']);
$tgl_lhr="$tanggal[2]-$tanggal[1]-$tanggal[0]";
?>
<tr bgcolor=<?Php echo "$warna" ?> class='data'>
<td><?php echo "$i" ?></td><?php $i++; ?>
<td><?php echo "$data[no_induk]" ?></td>
<td><?php echo "$data[nm_siswa]" ?></td>
<td><?php echo "$data[tmpt_lhr]" ?></td>
<td><?php echo "$tgl_lhr" ?></td>
<td><?php echo "$data[jenkel]" ?></td>
<td><?php echo "$data[pnddkn]" ?></td>
<td><?php echo "$data[alamat]" ?></td>
<td><?php echo "$data[no_telp]" ?></td>
<td><?php echo "$data[hsl_slksi]" ?></td>
<td><a href='input_siswa.php'>Tambah</a> | <a href='edit_siswa.php?no_induk=<?php echo "$data[no_induk]"; ?>'>Ubah</a> |<a href='delete_siswa.php?no_induk=<?php echo "$data[no_induk]"; ?>'> Hapus</a></td>
</tr>
<?php
}
?>
</table>
<p>
<?php
// mencari jumlah semua data dalam tabel siswa
$query = "SELECT COUNT(*) AS jumdata FROM tsiswa .$cari";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$jumdata=$data['jumdata'];
// menentukan jumlah halaman yang muncul berdasarkan jumlah semua data
$jumpage = ceil($jumdata/$dataperpage);
// menampilkan link previous
if ($nopage > 1) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($nopage-1).$cari."'><< sebelumnya</a>";
// memunculkan nomor halaman dan linknya
for($page = 1; $page <= $jumpage; $page++)
{
if ((($page >= $nopage - 3) && ($page <= $nopage + 3)) || ($page == 1) || ($page == $jumpage))
{
if (($showpage == 1) && ($page != 2)) echo "...";
if (($showpage != ($jumpage - 1)) && ($page == $jumpage)) echo "...";
if ($page == $nopage) echo " <b>".$page."</b> ";
else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page.$cari."'>".$page."</a> ";
$showpage = $page;
}
}
// menampilkan link next
if ($nopage < $jumpage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($nopage+1).$cari."'>Selanjutnya>></a>";
?>
</p>
<p> </p>
</center></div>
<?php include ('footer.php') ?>
</body>
</html>
<?php include("koneksi.php");
include("class_paging.php");
?>
<title></title>
<link rel="stylesheet" type="text/css" href="style_edit2.css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="jquery-1.4.3.min.js"></script>
<div>
<h1>Ubah Data Objek Wisata</h1><br>
<div>
<?php
$aksi="aksi_wisata.php";
switch($_GET[act]){
// Tampilkan wisata pd tabel
default:
echo "<table border=1>
<tr>
<th>No</th>
<th>Nama Objek Wisata</th>
<th>Alamat</th>
<th>Gambar</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Aksi</th>
</tr>";
$p = new Paging;
$batas = 10;
$posisi = $p->cariPosisi($batas);
$tampil=mysql_query("SELECT * FROM wisata ORDER BY id_wisata DESC LIMIT $posisi,$batas");
$no = $posisi+1;
while ($r=mysql_fetch_array($tampil)){
echo "<tr align=center>";
echo "<td>$no</td>";
echo "<td width=70>$r[nama_wisata]</td>";
echo " <td width=90>$r[alamat]</td>";
echo " <td width=40>$r[gambar]</td>";
echo "<td>$r[lat]</td>";
echo "<td>$r[lng]</td>";
echo "<td><a href=?hal=ubahwisata&jenis=wisata&act=edit_wisata&id=$r[id_wisata]>Edit</a>";
echo " | <a href=$aksi?jenis=wisata&act=hapus&id=$r[id_wisata]>Hapus</a>";
echo "</tr>";
$no++;
}
echo "</table>";
$jmldata=mysql_num_rows(mysql_query("SELECT * FROM wisata"));
$jmlhalaman = $p->jumlahHalaman($jmldata, $batas);
$linkHalaman = $p->navHalaman($_GET[halaman], $jmlhalaman);
echo "<br /> <br />";
echo "<div id=paging>Hal: $linkHalaman</div><br>";
break;
case "edit_wisata":
$edit = mysql_query("SELECT * FROM wisata WHERE id_wisata='$_GET[id]'");
$r = mysql_fetch_array($edit);
echo "<h2>Edit Data Objek Wisata</h2>
<form method=POST action=$aksi?jenis=wisata&act=edit_wisata>
<input type=hidden name=id value=$r[id_wisata]>
<table>
<tr><td>Nama Objek Wisata</td><td> : <input type=text name='nama_wisata' size=30 value='$r[nama_wisata]'></td></tr>
<tr><td>Alamat</td><td> : <input type=text name='alamat' size=30 value='$r[alamat]'></td></tr>
<tr><td>Gambar</td><td> : <input type=text name='gambar' size=30 value='$r[gambar]'></td></tr>
<tr><td>Latitude</td><td> : <input type=text name='lat' size=30 value='$r[lat]'></td></tr>
<tr><td>Longitude</td><td> : <input type=text name='lng' size=30 value='$r[lng]'></td></tr>";
echo "<tr><td colspan=2><input type=submit value=Ubah>
<input type=button value=Batal onclick=self.history.back()></td></tr>
</table>
</form>";
break;
}
?>
</div>
</div>
<?php
include "koneksi.php";
$act=$_GET[act];
$jenis=$_GET[jenis];
// =======================================================================================
//hapus wisata
if ($jenis=='wisata' AND $act=='hapus'){
mysql_query("DELETE FROM wisata WHERE id_wisata='$_GET[id]'");
header('location:kelola_objekwisata.php?hal=ubahwisata');
}
// Update wisata
elseif ($jenis=='wisata' AND $act=='edit_wisata'){
mysql_query("UPDATE perumahan SET nama_wisata = '$_POST[nama_wisata]',
alamat = '$_POST[alamat]',
gambar = '$_POST[gambar]',
lat = '$_POST[lat]',
lng = '$_POST[lng]'
WHERE id_wisata = '$_POST[id]'");
header('location:kelola_objekwisata.php?hal=ubahwisata');
}
?>
<?php
mysql_connect ('localhost','root','rahasia');
mysql_select_db ('abms');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tipedata = $_POST['tipe'];
$id = $_POST['id'];
switch($tipedata){
case 'unit':
$sql='SELECT kode_unit,nama_unit,produk FROM '.$tipedata.' WHERE kodeP = "'.$id'" ORDER BY nama_unit ASC';break;
case 'produk':
$sql='SELECT kodeP,produk FROM '.$tipedata.' ORDER BY produk ASC';break;
}
$kueri=mysql_query($sql);
echo '<option value=""></option>';
while($row=mysql_fetch_object($kueri)){
echo '<option value="'.$row->kodeP.'">';
switch($tipedata){
case 'unit':
echo $row->nama_unit;break;
case 'produk':
echo $row->produk;break;
}
echo '</option>';
}
}
?>
<script language="javascript">
function Load(data,primid){
$('#loading'+data).empty().append('<img src="img/ajax-loader.gif"/>');
$.post("js_unit.php",{tipe:data,id:primid},
function(result){
$('#cb'+data).html(result);
$('#loading'+data).empty();
}
);
}
$(function(){
Load('produk',0);
$('#cbproduk').change(
function(){
if($('#cbproduk option:selected').val() !=''){
Load('unit',$('#cbproduk option:selected').val());
}
}
);
});
</script>
<tr title="Required">
<td><b>Produk</b><span class="required">*</span></td>
<td>:</td>
<td><select name="produk" id="cbproduk" style="width:311px"></select></td>
</tr>
<tr title="Required">
<td><b>Unit</b><span class="required">*</span></td>
<td>:</td>
<td><select name="nama_unit" id="cbunit" style="width:311px"></select></td>
</tr>
<button>scan</button>