mysql_fetch_array()与mysql_fetch_assoc()、mysql_fetch_row()

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值