Professional Documents
Culture Documents
Tampilan Ubah
KODINGAN:
Koneksi
<?php
$host="localhost";
$user="root";
$pass="";
$database="db_kampus";
<tr>
<td>Nama</td>
<td>:</td>
<td><input type="text" name="txtnama"></td>
</tr>
<tr>
<td>Kelas</td>
<td>:</td>
<td><input type="text" name="txtkelas"></td>
</tr>
<tr>
<td colspan="4" align="center"><input type="submit" value="Simpan"><input type="reset"
value="Batal"> <a href="mahasiswa_tampil.php">Lihat Data Mahasiswa</a></td>
</tr>
</table>
</form>
Mahasiswa ganti
<?php
include "koneksi.php";
$kode=$_GET['kode'];
</table>
</form>
Simpan
u<?php
include "koneksi.php";
$a=$_POST['txtnim'];
$b=$_POST['txtnama'];
$c=$_POST['txtkelas'];
if($a=="")
{
echo "<script>window.alert(Isi Data Mahasiswa Dengan Lengkap');
window.location='mahasiswa_baru.php'</script>";
}
else
{
$cari=mysql_query("select * from tb_mhs where nim='$a'");
$data=mysql_fetch_array($cari);
if($data=='$a')
{
echo "<script>window.alert('NIM sudah ada');
window.location='mahasiswa_baru.php'</script>";
}
else
{
mysql_query("insert into tb_mhs values('$a','$b','$c')");
<?php
$n=1;
$query=mysql_query("select* from tb_mhs order by nim");
if(mysql_num_rows($query)>0){
while($data=mysql_fetch_array($query)){
?>
<tr>
<td align="center"><?php echo $n; ?></td>
<td align="center"><?php echo $data['nim']; ?></td>
<td align="center"><?php echo $data['nama']; ?></td>
<td align="center"><?php echo $data['kelas'];?></td>
<td align='center'><div align="center"><a href="mahasiswa_ganti.php?kode=<?=$data['nim']?
>">Ubah</a>|
<a href="mahasiswa_hapus.php?kode=<?=$data['nim']?>"
onclick="return confirm('Yakin Anda Akan
Menghapus Data<?=$data['nama']?>?')">Hapus</a></div>
</td>
</tr>
<?php
$n++; }}
?></table>
Ubah
<?php
include "koneksi.php";
$a=$_POST['txtnim'];
$b=$_POST['txtnama'];
$c=$_POST['txtkelas'];
mysql_query("update tb_mhs set nama='$b', kelas='$c' where nim='$a'")or die ("Query
Gagal".mysql_error());
{echo "<script>window.alert('Data Telah Diubah');
window.location='mahasiswa_tampil.php'</script>";}