应该将哪些代码写入post.php,该信息存储在数据库中,但只记录为数组
<a data-original-title="access" data-pk="1" data-type="checklist" data-value="" id="access"></a>
$(".editable-form #access").editable({
source: [
{value: 1,text: "a"},
{value: 2,text: "b"},
{value: 3,text: "c"},
{value: 4,text: "d"},
{value: 5,text: "f"}
],
url:"post.php",
name: "access"
});
post.php
if($_POST['name']=='access'){
$pk = $_POST['pk'];
$value=$_POST['value'];
//when i do echo $value result type array
//but i want just value = { 0: "1", 1: "2", 2: "3", 3: "4" }
$result = mysqli_query($mysqli,"UPDATE `books` SET `access`='$value' WHERE `id`='$pk'");
}
答案 0 :(得分:0)
使用此
json_encode(array(1, 2, 3, 4), JSON_FORCE_OBJECT);
返回
{"0":1,"1":2,"2":3,"3":4}