身份证件 变量行=$(this.parent().parent();//检索父行,以便在不重新加载整个页面的情况下删除它 var info=\'id\u app=\'+id\u app+\'&id\u user=\'+id\u user; $.ajax({ 类型:“POST”, url:“./functions/del_app.php”, 数据:信息, 成功:函数(){ $(行).remove();//删除行 } }); } });
删除完成后,请注意,您可以删除该行,而不是重新加载整个页面。根据我自己的经验,我将执行以下操作:身份证件 变量行=$(this.parent().parent();//检索父行,以便在不重新加载整个页面的情况下删除它 var info=\'id\u app=\'+id\u app+\'&id\u user=\'+id\u user; $.ajax({ 类型:“POST”, url:“./functions/del_app.php”, 数据:信息, 成功:函数(){ $(行).remove();//删除行 } }); } });,php,javascript,jquery,Php,Javascript,Jquery,删除完成后,请注意,您可以删除该行,而不是重新加载整个页面。根据我自己的经验,我将执行以下操作: <?php $user=$_SESSION['userid']; $con = db_connect(); $result = $con->query("SELECT `id_app`, `date_cr`,`id_user` FROM `applications` WHERE id_us
<?php
$user=$_SESSION['userid'];
$con = db_connect();
$result = $con->query("SELECT `id_app`, `date_cr`,`id_user`
FROM `applications`
WHERE id_user = $user");
?>
<?php if(($data = $result->num_rows)==0){ ?>
<p class="error">No data</p>
<?php } else { ?>
<script type="text/javascript" src="./functions/jquery-1.7.1.min.js"></script>';
<br/>
<br/>
<table id="tab_history">
<tr>
<td>Time when created
<td>
</tr>
<?php while(($data = $result->fetch_assoc())!==null) { ?>
<tr>
<td><?=$data['date_cr'] ?>
<td><button class="btnDel" data-id-app="<?=$data['id_app'] ?>" data-id-user="<?=$data['id_user'] ?>" type="button">
Delete</button>
</tr>
<?php } ?>
</table>
<?php } ?>
<script>
$(".btnDel").click(function (e) {
e.preventDefault();
if (confirm(\'Are you sure?\')){
var id_app = $(this).attr('data-id-app');
var id_user = $(this).attr('data-id-user');
$.ajax({
type: "POST",
url: "./functions/del_app.php",
data: {
id_app: id_app,
id_user: id_user
},
success: function(){
location.reload();
}
});
}
});
</script>
没有数据
';
创建时的时间
根据我自己的经验,我会做以下几点:
<?php
$user=$_SESSION['userid'];
$con = db_connect();
$result = $con->query("SELECT `id_app`, `date_cr`,`id_user`
FROM `applications`
WHERE id_user = $user");
?>
<?php if(($data = $result->num_rows)==0){ ?>
<p class="error">No data</p>
<?php } else { ?>
<script type="text/javascript" src="./functions/jquery-1.7.1.min.js"></script>';
<br/>
<br/>
<table id="tab_history">
<tr>
<td>Time when created
<td>
</tr>
<?php while(($data = $result->fetch_assoc())!==null) { ?>
<tr>
<td><?=$data['date_cr'] ?>
<td><button class="btnDel" data-id-app="<?=$data['id_app'] ?>" data-id-user="<?=$data['id_user'] ?>" type="button">
Delete</button>
</tr>
<?php } ?>
</table>
<?php } ?>
<script>
$(".btnDel").click(function (e) {
e.preventDefault();
if (confirm(\'Are you sure?\')){
var id_app = $(this).attr('data-id-app');
var id_user = $(this).attr('data-id-user');
$.ajax({
type: "POST",
url: "./functions/del_app.php",
data: {
id_app: id_app,
id_user: id_user
},
success: function(){
location.reload();
}
});
}
});
</script>
没有数据
';
创建时的时间
echo '<button class="btnDel" data-app-id="'.$data['id_app'].'" data-user-id="'.$data['id_user'].'" type="button">
Delete</button></td></tr>';
<script type="text/javascript">
$(".btnDel").click(function (e) {
e.preventDefault();
if (confirm(\'Are you sure?\')){
var id_app = $(this).attr('data-app-id'); // retrieve the app id
var id_user = $(this).attr('data-user-id'); // retrieve the user id
var row = $(this).parent().parent(); // retrieve the parent row so we can remove it without reloading the whole page
var info = \'id_app=\'+id_app+\'&id_user=\'+ id_user;
$.ajax({
type: "POST",
url: "./functions/del_app.php",
data: info,
success: function(){
$(row).remove(); // remove the row
}
});
}
});
</script>
<?php
$user=$_SESSION['userid'];
$con = db_connect();
$result = $con->query("SELECT `id_app`, `date_cr`,`id_user`
FROM `applications`
WHERE id_user = $user");
?>
<?php if(($data = $result->num_rows)==0){ ?>
<p class="error">No data</p>
<?php } else { ?>
<script type="text/javascript" src="./functions/jquery-1.7.1.min.js"></script>';
<br/>
<br/>
<table id="tab_history">
<tr>
<td>Time when created
<td>
</tr>
<?php while(($data = $result->fetch_assoc())!==null) { ?>
<tr>
<td><?=$data['date_cr'] ?>
<td><button class="btnDel" data-id-app="<?=$data['id_app'] ?>" data-id-user="<?=$data['id_user'] ?>" type="button">
Delete</button>
</tr>
<?php } ?>
</table>
<?php } ?>
<script>
$(".btnDel").click(function (e) {
e.preventDefault();
if (confirm(\'Are you sure?\')){
var id_app = $(this).attr('data-id-app');
var id_user = $(this).attr('data-id-user');
$.ajax({
type: "POST",
url: "./functions/del_app.php",
data: {
id_app: id_app,
id_user: id_user
},
success: function(){
location.reload();
}
});
}
});
</script>