在我的 AJAX 页面中,我想从数据库中获取数据。在我的第一页中,我有 del image
来删除记录。我将文件 cid 作为“rmvfile”传递到下一页,并在第二页上获取并显示它们。
在我的第一页中,我传递了 cf_id:
<img src="image/delete1.png" alt="delete" style="width:10px;height:10px" title="Remove" onclick="myFunction('.$fet['cf_id'].');">
function myFunction(cid) {
var rmvfile=cid;
if (confirm("Are you sure you want to Delete the file?") == true) {
if(cid!='') {
$.ajax({
type: 'post',
url: 'delete_cli_file.php',
data: {rmvfile: rmvfile},
});
}
}
}
我使用的第二页:
<?php
include "config.php";
$s = $_POST['rmvfile'];
$sel = "select cf_id from client_file where cf_id='".$_POST['rmvfile']."'";
$sel1 = mysql_query($sel);
$sfet = mysql_fetch_assoc($sel1);
$file_name = $sfet['file_name']; //not fetched
$echeck = "delete from client_file where cf_id='".$_POST['rmvfile']."'";
$echk = mysql_query($echeck);
$del = "delete from client_file where file_name = '$file_name' ";
$del1 = mysql_query($del);
?>
$echeck = "从 client_file 中删除 cf_id = '".$_POST['rmvfile']."'";
和 $sel="select cf_id from client_file where cf_id='".$_POST['rmvfile']."'";
正在工作。
我的问题是未在 $sfet['file_name']
中获取值。
最佳答案
尝试
$del1 = mysql_query( $del ).mysql_error();
关于php - 在 AJAX 页面中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30097618/