<?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');
}
?>