我正在尝试在JSON中显示数据库的表名,我该怎么做?更改我的PHP代码? Thant的帮助:)
PHP:
<?php
$connect = mysqli_connect($host, $user, $pwd, $db);
if(!$connect){
die("ERROR in connection: " . mysqli_connect_error());
}
$response = array();
$sql = "SELECT * FROM restaurant";
$result = mysqli_query($connect, $sql);
if(mysqli_num_rows($result) > 0){
while ($row = mysqli_fetch_assoc($result)){
array_push($response, $row);
}
}
else{
$response['success'] = 0;
$response['message'] = 'No data';
}
echo json_encode($response);
mysqli_close($connect);
?>
JSON:
[
("name Table":){
"id": "1",
"lieu": "",
"nom": "",
"description": "",
"photo": "",
"horraireopen": "",
"horraireclose": "",
},
]