1. 程式人生 > >day04_08-while查詢所有行

day04_08-while查詢所有行

user utf test select set oca cnblogs pri lin

<?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
    }
?>

  

day04_08-while查詢所有行