`

PHP的数据库操作

 
阅读更多
PHP数据库操作:
$db->select_db(dbname);//选择数据库
$result=$db->query($sql);//传递SQL语句查询结果集
$num_results=$result->num_rows;//检索查询结果
for($i=0;$i<$num_results;i++) {
//结果
}
$row=$result->fetch_assoc();//使用相关数组获取查询结果
echo stripslashes($row['name']);//利用stripslashes()函数整理显示获取的值
$row=$result->fetch_row($result);//使用列举数组获取查询结果
echo stripslashes($row[0]);//利用stripslashes()函数整理显示获取的值
$row=$result->fetch_object();//使用对象获取查询结果
$row->title;$row->author;//获取对象中的值
$result->free();//释放结果集
$db->close();//关闭数据库
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics