PHP mysqli_fetch_assoc到数组

时间:2016-02-16 18:18:42

标签: php mysql arrays

我正在尝试从mysql数据库中返回18个随机行。 可悲的是,它只在数组中添加一个返回,我做错了什么?

function get_random_items(){
    $this->connect();
    $random_items = $this->execute_query("SELECT * FROM Fds_items ORDER BY RAND() LIMIT 10");

    while($row = mysqli_fetch_assoc($random_items)){
        $key = (string)md5($design['url']);
        $response['designs'][$key] = array(
            "url" => (string)$row['url'],
            "name" => (string)$row['name'],
            "creator" => (string)$row['creator'],
            "key" => 'edits.php?username=' . $row['creator'] . '&key=' . $key
        );
    }

    return (isset($response) ? $response : false);
}

非常感谢任何帮助。

$this->connect(); //database connection
$this->execute_query(); //execute query to database

0 个答案:

没有答案