<?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 } ?>
原文:http://www.cnblogs.com/darkalex001/p/7529926.html