我有一个关于如何从img_ids
中删除所需号码的问题。正如您在img_ids
下面的表格中看到的,如68,67,66,65,64,
。我想删除例如67
,我怎样才能用PHP做到这一点。由于逗号,我的头脑混乱:S。从数据中删除所需号码
<div class="delete" id="67">Delete Image</div>
阿贾克斯
$("body").on("click", ".delete", function(){
var deleteimgid = $(this).attr("id");
var data = 'img='+deleteimgid;
$.ajax({
type: 'POST',
url: 'delete.php',
data: data,
cache: false,
beforeSend: function(){},
success: function(response){
}
});
});
delete.php
<?php
include_once 'inc.php';
if(isset($_POST['img'])){
$imgid = mysqli_real_escape_string($db, $imgid);
// Then what should be the query ?
// I am confused because of the commas.
}
?>
处理BLOB数据很容易想想你的规范化数据库,而不是存储逗号分隔的数据...真的很难处理 - 您将遇到与可维护性,可扩展性和性能相关的更大问题 –
**不要**将多个值存储在单个字段中。使用另一个表。 – axiac