差异mysql_fetch_array()和mysql_fetch_rows()函数
form:http://www.uphtm.com/php/254.html
如果我们不仔细看会发现象mysql_fetch_array()和mysql_fetch_rows()函数没有什么区别,但是细细的看你会发现它们区别还是蛮大了,如果各位对于此函数的区别不了解下文小编给各位整理mysql_fetch_array()和mysql_fetch_rows()的用法与例子。
mysql_fetch_array()函数参数
mysql_fetch_array() 函数从结果集中取得一行作为关联数组,或数字数组,或二者兼有
返回根据从结果集取得的行生成的数组,如果没有更多行则返回 false。
mysql_fetch_array(data,array_type)
array_type如下
MYSQL_ASSOC - 关联数组
MYSQL_NUM - 数字数组
MYSQL_BOTH - 默认。同时产生关联和数字数组
mysql_fetch_rows()函数参数
mysql_fetch_row() 函数从结果集中取得一行作为数字数组。
mysql_fetch_row(data)
从上面来看它们都是使用的数据指针。该数据指针是 mysql_query() 函数产生的结果了,但后面有一个参数是不一样的,mysql_fetch_array()有array_type参数而mysql_fetch_rows()没有。
那么用法有什么区别,下面看个例子
mysql_fetch_array()和mysql_fetch_rows()都能获取数据库的字段数据,具体区别可参照以整理的实例:
mysql_fetch_array()函数例子
- <?php
- $sql=”select * from user “;
- $query=mysql_query($sql);
- $result=mysql_fetch_array($query);
- echo $result[name];
- echo $resutlt[password];
- ?>
mysql_fetch_rows()函数例子
- <?php
- $sql=”select * from user “;
- $query=mysql_query($sql);
- $result=mysql_fetch_rows($query);
- echo $result[1];
- echo $resutlt[2];
- ?>
总结,mysql_fetch_array()是数组并且可以关联数组,而mysql_fetch_rows是对象不能关联数组,区别就在这里了
form:http://www.uphtm.com/php/254.html
- 提示小弟我<php while ($myrow=mysql_fetch_array($result)){ 这里出错了,但小弟我不知道这里有什么错了?求高手解答
- mysql_fetch_array(): supplied argument is not a valid MySQL result resource,该如何处理
- 无语的失误,mysql_fetch_array()
- php提示异常 mysql_fetch_array() expects parameter 1 to be resource, boolean given
- mysql_fetch_array()有关问题
- 请教为啥$row=mysql_fetch_array($result);这句老报错
- php出现Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result解决办法
- 【进去请严肃】从mysql取数据时提示Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
- while($rs=mysql_fetch_array($result)),该怎么处理
- mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:何解?解决办法
- mysql_fetch_array()的那些事,该怎么解决
- Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given i解决办法
- Warning: mysql_fetch_array() expects parameter 1,该如何解决
- mysql_fetch_array(): supplied argument is not a valid MySQL result resource解决方法
- Warning: mysql_fetch_array() expects parameter 1 to be resource解决思路
- mysql_fetch_array(): supplied argument is not a valid MySQL result resource,该怎么解决
- mysql_fetch_array($Sql)['字段名']这样的语法可不可以
- mysql_fetch_array() expects parameter 一 to be resource
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result reso,该怎么解决
- mysql_fetch_array()函数老是运行不成功,求解答
- 提示小弟我<php while ($myrow=mysql_fetch_array($result)){ 这里出错了,但小弟我不知道这里有什么错了?求高手解答
- mysql_fetch_array(): supplied argument is not a valid MySQL result resource,该如何处理
- 无语的失误,mysql_fetch_array()
- php提示异常 mysql_fetch_array() expects parameter 1 to be resource, boolean given
- mysql_fetch_array()有关问题
- 请教为啥$row=mysql_fetch_array($result);这句老报错
- php出现Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result解决办法
- 【进去请严肃】从mysql取数据时提示Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
- while($rs=mysql_fetch_array($result)),该怎么处理
- mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:何解?解决办法