php如何查询出来的结果
php查询结果的方法:1、通过mysql_result()函数获取结果数据集中的一行元素;2、通过mysql_fetch_row()函数将数字作为属性索引来获得属性值;3、使用mysql_fetch_array()函数直接获得属性值;4、通过mysql_fetch_object()函数分析查询结果。

php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用
本教程操作环境:windows7系统、PHP8.1版、Dell G3电脑。
php如何分析查询出来的结果?
PHP开发中四种查询返回结果分析,需要的朋友可以参考下。
1.
$connection=mysql_connect("localhost","root","password"); //连接并选择数据库服务器
mysql_select_db("test",$connection);
$query="insert into users(user_name)"; //在test数据库里插入一条数据
$query.="values('tuxiaohui')";
$result=mysql_query($query);
if(!$query)
echo "insert data failed!
";
else{
$query="select * from users"; //查询数据
$result=mysql_query($query,$connection);
for($rows_count=0;$rows_count<7;$rows_count++) //用mysql_result获得数据并输出,mysql_result() 返回 MySQL 结果集中一个单元的内容。
{
echo "用户ID:".mysql_result($result,$rows_count,"user_id")."
";
echo "用户名:".mysql_result($result,$rows_count,"user_name")."
";
}
}
?>
登录后复制

