Published June 27, 2019 by RIT with 0 comment

HOW TO DELETE AJAX IN PHP

assalamualaikum warohmatullohi wabarokatuh,
wa alaikum salam warohmatullohi wabarokatuh,

CARA HAPUS MENGGUNAKAN AJAX JQUERY
HOW TO DELETE WITH AJAX IN PHP AND MYSQL

1 - buatlah file index.php
2 - buat file lagi dengan nama proses_delete.php
3 - copy script dibawah ini sesuaikan dengan file index.php dan proses_delete.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<script type="text/javascript" src="jquery.js"></script>
 
<?php 
$koneksi = mysqli_connect('localhost','root','','test'); 
 
$q  = 'SELECT * FROM tb_siswa';
$q2 = mysqli_query($koneksi, $q);
 
?>
 
<table border="1" >
    <tr bgcolor="yellow" align="center">
        <td>NAME</td>
        <td>OPERATION</td>
    </tr>
 
<?php while ( $row = mysqli_fetch_array($q2)) { ?>
    <tr>
        <td><?php echo $row['nama']; ?></td>
        <td><button class='delete' id="<?php echo $row['id']; ?>">delete</button></td>
    </tr>
<?php } ?>
 
 
</table>
 
 
 
<script type="text/javascript">
  $(document).ready(function(){
        $(".delete").click(function(){
            var id_hapus = $(this).attr('id');
               $.ajax({
                      type:'POST',
                      url:'proses_delete.php',
                      data:'id='+id_hapus,
                      success:function(data){
                        location.reload();
                    }
                });         
             });
          });
</script>
1
2
3
4
5
6
7
8
9
<?php
include 'index.php'
 
$id $_POST['id'];
$q  "DELETE FROM tb_siswa WHERE id='$id'";
$q2 = mysqli_query($koneksi,$q);
return $q2;
 
 ?>

TAG TAGS :
simple code | simple code ajax | simple code ajax delete | code ajax delete | script ajax delete | script ajax delete php | free download script ajax | download script ajax | how to delete ajax php | how to ajax delete php | how to ajax delete in php and mysql | script delete ajax in php and mysql script simple delete ajax in php | simple delete ajax in php | download script delete ajax in | php download script ajax | delete ajax in php | delete ajax php | cara ajax dengan php | cara ajax delete | cara delete dengan ajax | cara delete data php | cara membuat delete php | cara delete dengan php | ajax jquery delete data | ajax delete data | script delete data di php | script delete php | php native | how to delete ajax using php | delete using ajax | how to delete php |


BACA JUGA :
      edit

0 comments:

Post a Comment