Langsung ke konten utama

Edit dan Hapus Data PHP MYSQL




EDIT / UPDATE DATA

1. Coding

edit_siswa.php

  <form name="form1" method="post" action="update_siswa.php"> 
      <table width="400" border="0" align="center" cellpadding="1" cellspacing="1"
    bordercolor="#FFFF99" bgcolor="#FF0000"> 
        <tr bgcolor="#FFFFCC"> 
          <td height="50" colspan="2"><div align="center">EDIT DATA</div></td> 
        </tr> 
        <?php 
          include ("koneksi.php");     
          $sqlTampil="select * from siswa Where nis='$_GET[nis]'"; 
          $qryTampil=mysql_query($sqlTampil); 
          $dataTampil=mysql_fetch_array($qryTampil); 
        ?> 
        <tr bgcolor="#FFFFFF"> 
          <td height="40">Nis </td> 
          <td>: 
          <input name="nis" type="text" id="nis" readonly value="<?php
  echo $dataTampil['nis']; ?>"></td> 
        </tr> 
        <tr bgcolor="#FFFFFF"> 
          <td height="40">Nama </td> 
          <td>: 
          <input name="nama_siswa" type="text" id="nama_siswa" value="<?php
  echo $dataTampil['nama']; ?>"></td> 
        </tr> 
        <tr bgcolor="#FFFFFF"> 
          <td>&nbsp;</td> 
          <td height="50"><input type="submit" name="Submit" value="Simpan"></td> 
        </tr> 
      </table> 
    </form> 

update_siswa.php

<?php
include ("koneksi.php");
     
    $update="UPDATE siswa SET
        nama='$_POST[nama_siswa]' WHERE nis='$_POST[nis]'"; 

    mysql_query($update); 
     
    echo "<center>Data Berhasil Di Update<center>"; 
    echo "<center><h3><a href='tampil_siswa.php'>Back</a></h3></center>"; 
?>


hapus_siswa.php

<?php
include ("koneksi.php");       
$delete="Delete from siswa WHERE nis='$_GET[nis]'";  

mysql_query($delete) or die ("Error bos");  
echo "<center><h3>Data berhasil di hapus</h3></center>";  
echo "<center><h3><a href=tampil_siswa.php>Back</a></h3></center>";  
?>  



Komentar

Postingan populer dari blog ini

Membuat Multimedia HTML - Youtube

Listing program html index.html <!DOCTYPE html> <html> <head> <title>Multimedia HTML</title> </head> <body> <table border="0" bgcolor=pink > <tr> <td colspan="2" height="50" width="600" bgcolor=pink> <img src="../media/image/cover.jpg" width="800" height="50"></td> </tr> <td width="600" align="center" bgcolor=black> <video width="320" height="240" controls> <source src="https://www.youtube.com/watch?v=sNY7aPVzgVU&list=RDsNY7aPVzgVU&start_radio=1" type="video/mp4"> </video> <audio controls> <source src="../media/audio/masiv.mp3" type="audio/mpeg"> </audio> </td> <td> <table border="0"> ...

FORM INPUT DAN CETAK BIODATA SISWA

1. Desain LAyout Keterangan : Pallete 2. Program   private void BtnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                              // TODO add your handling code here:         int Indexcombo;         String Pilihan;         char kelamin;         Indexcombo = cbagama.getSelectedIndex();         Pilihan = (String)cbagama.getSelectedItem();         if (RbLaki.isSelected())            kelamin = 'L';          else            kelamin = 'P';                 AreaResume.setText("Nama                 :  "+tfnama.getText()+...