javascript - 更新仅更新所选数据的动态图像
问题描述
我很难解决我的代码面临的问题。而不是仅仅更新我应该编码的记录,例如,我只是要更新我的“谷歌旅游套餐”的图像,而不是仅仅更新它的图像,它会更新所有记录,所以发生的事情就是我的数据库中的图像都是一样的。我认为问题出在 where 子句上。
这是在 xammp v3.2.2 中运行 sql 和 apache 的 windows 服务器
$targetDir = "../../../../../../img/itinerary/";
$fileName = basename($_FILES["itinerary_img"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
$itinerary_id = $_GET['id'];
if(!empty($_FILES["itinerary_img"]["name"]))
{
$allowTypes = array('jpg','png','jpeg','gif','pdf');
if(in_array($fileType, $allowTypes))
{
if(move_uploaded_file($_FILES["itinerary_img"]["tmp_name"],
$targetFilePath))
{
// Insert image file name into database
$insert ="UPDATE 'tms_itinerary' SET itinerary_img = ".$fileName."' WHERE itinerary_id = '".$itinerary_id."' ";
$result2 = mysqli_query($mysqli, $insert);
if($result2){
$statusMsg = "The file ".$fileName. " has been uploaded successfully.";
}else{
$statusMsg = "File upload failed, please try again.";
}
}else{
$statusMsg = "Sorry, there was an error uploading your file.";
}
}else{
$statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, & PDF files are allowed to upload.';
}
}else{
$statusMsg = 'Please select a file to upload.';
}
我希望输出仅更改我正在更新的图像,而不是所有 itinerary_image
解决方案
推荐阅读
- node.js - 即使我通过浏览器下载了最新的稳定版本,为什么我的 ubuntu 终端 v10 中的节点版本仍然存在?
- python - 如何根据输入创建不同的对象?
- angular - GoCD 将 dist 文件夹复制到主机系统
- python - 如何使用 Python Qt 创建拖放图像重新排序?
- nopcommerce - 为什么 nopcommerce 商店中的支付插件禁用信息支付点击
- java - iBatis:execute() 可以触发其他事件吗?
- flutter - 你如何在谷歌播放控制台上传apk文件?
- hyperlink - 将 https:// url 转换为 file:// url
- typescript - Typescript如何在父函数上使用`unknown`类型来确定子函数的类型?
- blazor - 有人 Blazor 远程验证工作吗?