参数 | 描述 |
---|---|
data | 必需。要使用的数据指针。该数据指针是从 mysql_query() 返回的结果。 |
注释:mysql_fetch_assoc() 和用 mysql_fetch_array() 加上第二个可选参数 MYSQL_ASSOC 完全相同。它仅仅返回关联数组。这也是 mysql_fetch_array() 初始的工作方式。
提示:如果在关联索引之外还需要数字索引,用 mysql_fetch_array()。
注释:本函数返回的字段名是区分大小写的。
<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
{
die(Could not connect: . mysql_error());
}
$db_selected = mysql_select_db("test_db",$con);
$sql = "SELECT * from Person WHERE Lastname=Adams";
$result = mysql_query($sql,$con);
print_r(mysql_fetch_assoc($result)
);
mysql_close($con);
?>
输出:
Array ( [LastName] => Adams [FirstName] => John [City] => London )
制作:
http://www.7di.net 生活网搜集整理 参考: http://www.w3school.com.cn/php/func_mysql_fetch_assoc.asp |