with From posting Ajax , Ajax, Ajax .
<form action='/clinic form/appoint/delete.php'=<?php echo $rows['id']; ?>' method="post">
<input type="hidden" name="id" value="<?php echo $rows['id']; ?>">
<input type="submit" name="submit1" value="Done">
</form>
getdata.php
<button type="button" class="DelMe" data-id="<?php echo $rows['id']; ?>">Delete Me</button>
getdata.php
<tr>
<tr class="deleted">
, <?php } } ?>
Ajax delete, delete Ajax DOM.
<?php } ?>
<script>
$(document).ready(function(){
$(".DelMe").on('click', function(){
var DelId =$(this).data('id');
var dataString = 'DelId='+ DelId;
$.ajax({
type: "POST",
url: "delete.php",
data: dataString,
cache: false,
success: function(msg) {
$(this).parents(".deleted").hide(500);
}
});
});
});
</script>
<?php } ?>
getdata.php
:
<?php require_once ('../include/global.php');
if($_POST['seldate']) {
$selDate = $_POST['seldate'];
$sql="SELECT * FROM clinic.appoint WHERE date='$selDate'";
$result = mysqli_query($con, $sql) or die($sql."<br/><br/>".mysql_error());
while($rows=mysqli_fetch_array($result)){
?>
<tr class="deleted">
<td scope="row"><?php echo $rows['time'] ?></td>
<td scope="row"><?php echo $rows['name'] ?></td>
<td scope="row"><?php echo $rows['date'] ?></td>
<td scope="row"><button type="button" class="DelMe" data-id="<?php echo $rows['id']; ?>">Delete Me</button></td>
</tr>
<?php } ?>
<script>
$(document).ready(function(){
$(".DelMe").on('click', function(){
var DelId =$(this).data('id');
var dataString = 'DelId='+ DelId;
$.ajax({
type: "POST",
url: "delete.php",
data: dataString,
cache: false,
success: function(msg) {
$(this).parents(".deleted").hide(500);
}
});
});
});
</script>
<?php } ?>
PHP delete.php
<?php require_once ('../include/global.php');
if($_POST['DelId']) {
$DelId = $_POST['DelId'];
$sql="DELETE FROM appoint WHERE id='$DelId'";
$result = mysqli_query($con, $sql) or die($sql."<br/><br/>".mysql_error());
$rowcount=mysqli_num_rows($result);
if ($rowcount > 0) {
echo "success";
} else {
echo "false";
}
}
?>
, .