将查询存储到json_encode中

时间:2016-11-21 08:47:09

标签: javascript php html json

我有3个连续运行的查询,我想将Case_ID存储到

$json_out = "[" . json_encode(array("result"=> )) . "]";

这样我就可以通过localstorage将它存储在HTML中。我如何实现这一目标?

PHP

$query = "insert into `Case`(`informant_userid`,`CaseName`,`CaseTime`) values ('" . $informant_userid . "','" . $CaseName . "',now());";
$query.= "insert into Picture (Case_Pic,Case_ID) values ('" .addslashes($imagefile). "', LAST_INSERT_ID());" ;    
$query.= "SELECT `Case_ID` from `Case` ORDER BY `Case_ID` DESC LIMIT 1 ";

Echo($query);
$result = $conn->multi_query($query);

$count = $result->fetch_array(MYSQLI_NUM);
$json_out = "[" . json_encode(array("result"=>$count[0])) . "]";


if (!$result){
    $json_out = "[" . json_encode(array("result"=>0)) . "]";        
}
else {
    $json_out = "[" . json_encode(array("result"=> )) . "]";        
}

echo $json_out;

0 个答案:

没有答案