Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:如何在表格的正确位置显示上传的文件名_Php_Mysql_File Upload_Pdo - Fatal编程技术网

PHP:如何在表格的正确位置显示上传的文件名

PHP:如何在表格的正确位置显示上传的文件名,php,mysql,file-upload,pdo,Php,Mysql,File Upload,Pdo,我被要求创建一个网站(用作内部资源),其中MySQL表的结果显示为HTML表。每个记录都有一个上传按钮,人们可以在这里上传特定的图像和PDF文件。然后,他们可以发送此记录列表和上载的文件 我已经设法使一个(非常)基本的上传工作。我的问题是,我不知道如何只在应该上传的记录中显示上传的文件名。我怎样才能做到这一点 我尝试过这个愚蠢的方法,只是在一个中显示{$file},当然,这会在每条记录中显示文件名。如果t20pctID不等于文件名的一部分,我尝试将$file设置为空,但结果是出现了一个无休止的循

我被要求创建一个网站(用作内部资源),其中MySQL表的结果显示为HTML表。每个记录都有一个上传按钮,人们可以在这里上传特定的图像和PDF文件。然后,他们可以发送此记录列表和上载的文件

我已经设法使一个(非常)基本的上传工作。我的问题是,我不知道如何只在应该上传的记录中显示上传的文件名。我怎样才能做到这一点

我尝试过这个愚蠢的方法,只是在一个
中显示
{$file}
,当然,这会在每条记录中显示文件名。如果
t20pctID
不等于文件名的一部分,我尝试将$file设置为空,但结果是出现了一个无休止的循环,显示相同的记录,然后我的Firefox崩溃

这是我正在使用的代码,它是对几个外部资源上的代码的改编。先谢谢你

Claims.php(遵循类似于在线商店购物车的模式)


很显然,我很有天赋,通过如下更新
upload.php
解决了这个问题

//previous code as in the OP
 $file_destination = $uploads_dir_name.$file_name_new;

if (move_uploaded_file($file_tmp, $file_destination)) {
    $query_update = "UPDATE cart SET file='$file_name_new' WHERE t20pctID='$t20pctID' AND user_id='$user_id'";
    $stmt = $con->prepare($query_update);
    $stmt->execute();
    header('Location: claims.php?action=file_uploaded&song_id=' . $t20pctID . '&file='.$file_name_new);
    } else {
    header('Location: claims.php?action=upload_failed&song_id=' . $t20pctID);
}
//code after this line as in the OP

很显然,我很有天赋,通过如下更新
upload.php
解决了这个问题

//previous code as in the OP
 $file_destination = $uploads_dir_name.$file_name_new;

if (move_uploaded_file($file_tmp, $file_destination)) {
    $query_update = "UPDATE cart SET file='$file_name_new' WHERE t20pctID='$t20pctID' AND user_id='$user_id'";
    $stmt = $con->prepare($query_update);
    $stmt->execute();
    header('Location: claims.php?action=file_uploaded&song_id=' . $t20pctID . '&file='.$file_name_new);
    } else {
    header('Location: claims.php?action=upload_failed&song_id=' . $t20pctID);
}
//code after this line as in the OP
//previous code as in the OP
 $file_destination = $uploads_dir_name.$file_name_new;

if (move_uploaded_file($file_tmp, $file_destination)) {
    $query_update = "UPDATE cart SET file='$file_name_new' WHERE t20pctID='$t20pctID' AND user_id='$user_id'";
    $stmt = $con->prepare($query_update);
    $stmt->execute();
    header('Location: claims.php?action=file_uploaded&song_id=' . $t20pctID . '&file='.$file_name_new);
    } else {
    header('Location: claims.php?action=upload_failed&song_id=' . $t20pctID);
}
//code after this line as in the OP