How do I store all results from an SQL query in a multidimensional array?

后端 未结 5 1301
心在旅途
心在旅途 2021-02-08 17:46

hello every one i want to convert my array into other array type , plz help me out . I m using this

$row = mysql_fetch_array($result, MYSQL_ASSOC); 
5条回答
  •  离开以前
    2021-02-08 18:01

    The only way to avoid doing a loop would to use PDO (PHP Data Objects) which is a better way to access database in PHP and you could do this :

    $pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
        
    $q = $pdo->query('select * from yourtable');
    $r = $q->fetchAll();
        
    var_dump($r);
    

提交回复
热议问题