如何显示姓名表?

时间:2019-10-05 09:01:46

标签: php mysql json

我正在尝试在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": "",
    },
]

0 个答案:

没有答案