day04_08-while查询所有行

<?php
    $link = @mysql_connect('localhost','root','');
    mysql_query('use test',$link);
    mysql_query('set names utf8',$link);
    
    $res = mysql_query('select * from user');
    //var_dump($res);
    print_r(mysql_fetch_assoc($res));
    
    while($row = mysql_fetch_assoc($res)){
        //print_r(mysql_fetch_assoc($res));//只会打印出偶数行,因为while在前面已经执行过一次,所以需要加上一个变量赋值,如$row;
        print_r($row);//打印数组需要print_r
    }
?>

  

posted on 2017-09-16 08:17  darkalex001  阅读(122)  评论(0编辑  收藏  举报

导航