php - 在 AJAX 页面中获取数据

标签 php jquery ajax

在我的 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/

相关文章:

php - 无法使用 Gmail PHP API 获取电子邮件正文

javascript - 将数据移动到 $.ajax 中?

javascript - 如何实现类似facebook点赞/评论的部分刷新?

ajax - 跨域请求的 502 错误网关错误

php - 如何在本地 apache (php) 中设置 aws DB 常量?

php - 注册表类的目的是什么?

php - OpenSSL 已启用但无法找到包装器 "ssl"

javascript - 通过 JQuery 更改表单标签上的标签

php - 用户名或电子邮件存在时不返回错误

ajax - 使用隐藏的ajax上传文件时如何检测iframe接收响应