MySQL数组函数–mysql_fetch_array()

MySQL有一类独特的函数,称为MySQL数组函数,下面为您介绍的就是其中的MySQL数组函数–mysql_fetch_array()。

mysql_fetch_array 从结果集中取得一行作为关联数组,或数字数组,或二者兼有。

依次调用此函数也会返回结果集的下一行。

该MySQL数组函数语法:mysql_fetch_array(resource result, result type)

返回结果一般为:
 Array ( [0] => 1 [ID] => 1 [1] => 58.215.76.161 [IP] => 58.215.76.161 [2] => linux [description] => linux [3] => 1 [4] => http [protocol] => http [5] => 80 [port] => 80 [6] => http [7] => check_http [command] => check_http )

如果只需要关联数组则命令参数为
  mysql_fetch_array($rs,MYSQL_ASSOC) 相当于函数mysql_fetch_assoc()。

返回结果为

Array ( [ID] => 1 [IP] => 58.215.76.161 [description] => linux [protocol] => http [port] => 80 [command] => check_http )

如果只需要数字数组则命令参数为

mysql_fetch_array($rs,MYSQL_NUM) 相当于函数mysql_fetch_row().

返回结果为

Array ( [0] => 1 [1] => 58.215.76.161 [2] => linux [3] => 1 [4] => http [5] => 80 [6] => http [7] => check_http )

 

 

【编辑推荐】

MySQL日期的相关函数介绍

带您深入了解MYSQL Cast函数

查看三种MySQL字符集的方法

查看MySQL默认字符集

MySQL外键在数据库中的作用

 

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/280854.html<

(0)
管理的头像管理
上一篇2025-05-12 17:33
下一篇 2025-05-12 17:34

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注