<?php
//1、第一步【建立连接】
$conn = mysqli_connect('localhost','root','123456') or die('数据库连接失败!'); //2、第二步【选择数据库】
mysqli_select_db($conn,'new_kt'); //3、第三步【设置字符集】
mysqli_set_charset($conn,'utf8'); //4、第四步【准备sql语句】
$sql = 'select * from `user` limit 10'; //5、第五步【执行sql语句】
$result = mysqli_query($conn,$sql);
$new_result = [];//数组结果集
//while($row = mysqli_fetch_array($result)){
//$new_result[]=$row;
//} //6、第六步【获取结果集】
//或者如下方式
$new_result = mysqli_fetch_all($result,MYSQLI_ASSOC);
$nums = mysqli_num_rows($result);//数据条数 //7、第七步【释放临时数据】
mysqli_free_result($result); //8、第八步【关闭连接】
mysqli_close($conn); ?>

最新文章

  1. mac终端命令
  2. Java提高篇——理解String 及 String.intern() 在实际中的应用
  3. Dell DRAC的重启方法
  4. (转) PowerDesigner逆向工程导入MYSQL数据库总结
  5. pycharm实用快捷键
  6. oracle sql获取随机数
  7. Eclipse : cannot open output file(c++)
  8. 一个简洁通用的调用DLL函数的帮助类
  9. [Regex Expression] Use Shorthand to Find Common Sets of Characters
  10. (Pre sell) ZOPO ZP998 (C2 II) 5.5 inch smart phone True Octa Core MTK6592 1920X1080 FHD screen 401 ppi 2GB/32GB 14.0Mp camera-in Mobile Phones from Electronics on Aliexpress.com
  11. 关于对WEB标准以及W3C的理解与认识问题
  12. Oozie安装时放置Mysql驱动包的总结(网上最全)
  13. 读了前半本&lt;Thinking in Java&gt;
  14. Windows DLL资料整理
  15. java Servlet文件拷贝的模板代码
  16. bzoj5100 [POI2018]Plan metra 构造
  17. 洛谷P2604 网络扩容 拆点+费用流
  18. 使用Eclipse绑定Tomcat并发布应用
  19. Docker:镜像构建与进入容器总结
  20. activeX

热门文章

  1. PHP 调试脚本
  2. Canvas动画基础之碰撞检测
  3. 前端知识点总结——jQuery(上)
  4. WCF 入门调用实例教程
  5. 『嗨威说』算法设计与分析 - 动态规划思想小结(HDU 4283 You Are the One)
  6. 【原创】docker在Ubuntu下1小时快速学习
  7. Python的Argparse模块是什么?
  8. Prometheus(二):Prometheus 监控Windows机器
  9. Dockerfile 指令详解
  10. [AI开发]零数学公式告诉你什么是(卷积)神经网络