Menambahhkan kolom EDIT DATA pada tabel di tampil.php tambahkan skrip berikut di bawah kolom delete
==================
Di bawah NAMA KOLOM DELETE
=========================
<td bgcolor='#000FFF'>Edit</td>
===============
Dibawah rekursif data untuk menampilkan data copy paste di bawah Delete
================
<td align='center' bgcolor='#00FFFF'><a href=update.php?id={$row['id']}/>Edit</a></td>
=============================
BUATLAH FILE BERNAMA update.php dengan isinya sebagai berikut :
=========================
<html>
<head>
<title>Edit Data </title>
<style type="text/css">
.labelfrm{
display:block;
font-size:small;
margin-top:5px;
}
.error{
font-size:small;
color:red;
}
</style>
</head>
<body align="center">
<?php
include "menu.php";
?>
<?php
include "koneksi.php";
$id=$_GET['id'];
$query = mysqli_query($dbconnect, "SELECT * FROM siswa where id='$id'")
or die (mysqli_error($dbconnect));
?>
<h1 alignment"center">EDIT DATA</h1>
<form action="skripupdate.php" method="post">
<table border="0" align="center">
<?php
while ($row = mysqli_fetch_array($query)){
?>
<input type="hidden" name="id" value="<?php echo "{$row['id']}";?>"/>
<tr>
<td>Nama</td><td><input type="text" name="nama" maxlength="25" size="25" value="<?php echo "{$row['nama']}";?>" /></td>
</tr>
<tr>
<td>Alamat</td><td><input type="text" name="alamat" maxlength="30" size="30" value="<?php echo "{$row['alamat']}";?>" /></td>
</tr>
<tr>
<td>tahun</td><td><input type="text" name="tahun" value="<?php echo "{$row['tahun']}";?>" /></td>
</tr>
<tr>
<td>kelas</td><td><input type="text" name="kelas" value="<?php echo "{$row['kelas']}";?>" /></td>
</tr>
<tr>
<td>rombel</td><td><input type="text" name="rombel" value="<?php echo "{$row['rombel']}";?>" /></td>
</tr>
<tr><td></td><td align="center"><input type="submit" value="Simpan" name="simpan" /></td>
</tr>
<?php
}
?>
</table>
</form>
</body>
</html>
===============
Kemudian Buatlah file dengan nama skripupdate.php dengan isinya sebagai berikut :
<?php
include "koneksi.php";
$id=$_POST['id'];
$nama=$_POST['nama'];
$alamat=$_POST['alamat'];
$tahun=$_POST['tahun'];
$kelas=$_POST['kelas'];
$rombel=$_POST['rombel'];
$sql = "update siswa set nama='$nama',alamat='$alamat', tahun='$tahun', rombel='$rombel' where id='$id'";
if(mysqli_query($dbconnect, $sql)){
echo "Records were updated successfully.";
echo "<script> location.replace('tampil.php'); </script>";
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($dbconnect);
}
// Close connection
mysqli_close($dbconnect);
?>
Langganan:
Posting Komentar (Atom)
https://run-of-the-mill-pay.000webhostapp.com/latihan/tampil.php
BalasHapustugas Kukuh cahyo widodo
Hapushttps://aniskhoirunnisa111.000webhostapp.com/latihan/tampil.php
BalasHapusANIS KHOIRUNNISA
https://startled-guns.000webhostapp.com/latihan/tampil.php
BalasHapusTUGAS:PUTRI ARDIANA
Tugas by: Siti Muasaroh
BalasHapushttps://sitimuasaroh.000webhostapp.com/latihan/tampil.php
https://epistatic-stubs.000webhostapp.com/latihan2/tampil.php
BalasHapusudah pak
by muhammad syafii
Tugas by: Febriani
BalasHapushttps://febriiani.000webhostapp.com/latihan/tampil.php
https://kiki111.000webhostapp.com/tampil.php
BalasHapustugas kiki selvia
https://taqiyyur.000webhostapp.com/latihan/tampil.php
BalasHapusudah
Tugas Widi Maula
BalasHapushttps://tok-dalang.000webhostapp.com/latihan/tampil.php
Tugas Alfiyan Syah Putra Siregar
BalasHapushttps://syahsiregar.000webhostapp.com/latihan/tampil.php
novita salbianti
BalasHapushttps://salbianti.000webhostapp.com/latihan/tampil.php