总结:mysql_fetch_object 把记录作来一个对象来处理,像我们用类时就要用->访问,mysql_fetch_array 把记录保存到一个数据所以可以用$rs['下标名'] 或$rs[0]数组编号.
PHP实例代码如下:
- $conn=mysql_connect("127.0.0.1","root","root");
- mysql_select_db("ip");
- $sql="select * from adminblog ";
- $result=mysql_query($sql,$conn);
-
- while($rs=mysql_fetch_array($result))
- {
- echo $rs->username;
- echo $rs->password;
- }
-
-
- while($rs=mysql_fetch_array($result))
- {
- echo $rs['username'];
- echo $rs['password'];
- }
-
-
-
-
- while($rs=mysql_fetch_object($result))
- {
- echo $rs['username'];
-
- }
-
-
-
- while($rs=mysql_fetch_object($result))
- {
- echo $rs->username;
-
- }
-
|