php如何打印数据库里面所有数据?

解决方案 »

  1.   

    while($row = mysql_fetch_assoc($result))
    {
      print_r($row);
    }
      

  2.   

    <?php
    function list_all_sites(){
        $row = $rows = array();
        $sql='select * from sites';
        $result = mysql_query($sql);
        while($row = mysql_fetch_assoc($result)){
            $rows[] = $row; //不是$row[index] ?这是什么用法?
        }
        print_r($rows);
    }
    ?>
      

  3.   

    $rows[] = ……这是php的动态增加数组新的元素相当于 array_merge($rows, $row);