📜  sql 结果到 javascript 数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:46.057000             🧑  作者: Mango

代码示例1
prepare("SELECT category.name FROM category")) {
        $stmt->bind_result($name);
        $OK = $stmt->execute();
    }
    //put all of the resulting names into a PHP array
    $result_array = Array();
    while($stmt->fetch()) {
        $result_array[] = $name;
    }
    //convert the PHP array into JSON format, so it works with javascript
    $json_array = json_encode($result_array);
?>