mysql_fetch_array()
从结果集中取得一行作为关联数组或者索引数组
array (size=2)
0 =>
array (size=10)
0 => string '7' (length=1)
'id' => string '7' (length=1)
1 => string '2' (length=1)
'pid' => string '2' (length=1)
2 => string '????' (length=4)
'catename' => string '????' (length=4)
3 => string '0' (length=1)
'cateorder' => string '0' (length=1)
4 => string '0' (length=1)
'createtime' => string '0' (length=1)
1 =>
array (size=10)
0 => string '8' (length=1)
'id' => string '8' (length=1)
1 => string '2' (length=1)
'pid' => string '2' (length=1)
2 => string '????' (length=4)
'catename' => string '????' (length=4)
3 => string '0' (length=1)
'cateorder' => string '0' (length=1)
4 => string '0' (length=1)
'createtime' => string '0' (length=1)
mysql_fetch_assoc()
从结果集中取得一行作为关联数组
array (size=2)
0 =>
array (size=5)
'id' => string '7' (length=1)
'pid' => string '2' (length=1)
'catename' => string '????' (length=4)
'cateorder' => string '0' (length=1)
'createtime' => string '0' (length=1)
1 =>
array (size=5)
'id' => string '8' (length=1)
'pid' => string '2' (length=1)
'catename' => string '????' (length=4)
'cateorder' => string '0' (length=1)
'createtime' => string '0' (length=1)
mysql_fetch_row()
从结果集中取得一行作为索引数组
array (size=2)
0 =>
array (size=5)
0 => string '7' (length=1)
1 => string '2' (length=1)
2 => string '????' (length=4)
3 => string '0' (length=1)
4 => string '0' (length=1)
1 =>
array (size=5)
0 => string '8' (length=1)
1 => string '2' (length=1)
2 => string '????' (length=4)
3 => string '0' (length=1)
4 => string '0' (length=1)
另外注意,这几个函数都只是从结果集中仅仅取得一条记录,因此我们还需要遍历结果集才能获取所有数据,例如
$results = array(); while($result1 = mysql_fetch_row($result)){ $results[] = $result1; }