根据我以前的帖子(Why the query didn't update after click at the update button?)
声明
如何将部分代码转换为准备好的语句?
edit.php
data = {}
data['a'] = A
data['b'] = B
json_data = json.dumps(data)
print(json_data)
上面的给定链接中已经提供了更多代码。
答案 0 :(得分:1)
// while testing add
ini_set('display_errors', 1);
ini_set('log_errors',1);
error_reporting(E_ALL);
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
if (isset($_GET['id']))
{
$update = true;
$sql = "SELECT * FROM crimenews WHERE crimenews_id=?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('i', $_GET['id']);
$stmt->execute();
$res = $stmt->get_result();
if($res->num_rows == 1)
{
// fetch_assoc() returns just an assoc array and not the numeric array as well
$row = $res->fetch_assoc();
$category = $row['crimenews_cat'];
$url = $row['crimenews_url'];
$datetime = $row['crimenews_datetime'];
$lat = $row['crimenews_locationLat'];
$lng = $row['crimenews_locationLong'];
}
}