Beruflich Dokumente
Kultur Dokumente
DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
function tambah($koneksi){
if (isset($_POST['btn_simpan'])){
$id = time();
$nm_tanaman = $_POST['nm_tanaman'];
$hasil = $_POST['hasil'];
$lama = $_POST['lama'];
$tgl_panen = $_POST['tgl_panen'];
if($_GET['aksi'] == 'create'){
header('location: index.php');
} else {
?>
<fieldset>
<legend><h2>Tambah data</h2></legend>
<br>
<label>
</label>
<br>
<p><?php echo isset($pesan) ? $pesan : "" ?></p>
</fieldset>
</form>
<?php
function tampil_data($koneksi){
echo "<fieldset>";
echo "<tr>
<th>ID</th>
<th>Nama Tanaman</th>
<th>Hasil Panen</th>
<th>Lama Tanam</th>
<th>Tanggal Panen</th>
<th>Tindakan</th>
</tr>";
while($data = mysqli_fetch_array($query)){
?>
<tr>
<td>
</td>
</tr>
<?php
echo "</table>";
echo "</fieldset>";
function ubah($koneksi){
// ubah data
if(isset($_POST['btn_ubah'])){
$id = $_POST['id'];
$nm_tanaman = $_POST['nm_tanaman'];
$hasil = $_POST['hasil'];
$lama = $_POST['lama'];
$tgl_panen = $_POST['tgl_panen'];
$perubahan = "nama_tanaman='".$nm_tanaman."',hasil_panen=".
$hasil.",lama_tanam=".$lama.",tanggal_panen='".$tgl_panen."'";
if($_GET['aksi'] == 'update'){
header('location: index.php');
} else {
if(isset($_GET['id'])){
?>
<hr>
<form action="" method="POST">
<fieldset>
<legend><h2>Ubah data</h2></legend>
<br>
<label>
</label>
<br>
</fieldset>
</form>
<?php
}
// --- Tutup Fungsi Update
function hapus($koneksi){
$id = $_GET['id'];
if($hapus){
if($_GET['aksi'] == 'delete'){
header('location: index.php');
// ===================================================================
if (isset($_GET['aksi'])){
switch($_GET['aksi']){
case "create":
tambah($koneksi);
break;
case "read":
tampil_data($koneksi);
break;
case "update":
ubah($koneksi);
tampil_data($koneksi);
break;
case "delete":
hapus($koneksi);
break;
default:
tambah($koneksi);
tampil_data($koneksi);
} else {
tambah($koneksi);
tampil_data($koneksi);
?>
</body>
</html>