如何用php实现数据库的连接、增删改、连接查询。操作步骤
参考一下
- 链接数据库服务器
- 选择数据库
- 执行sql语句
- 释放结果集
5 关闭与mysql 的链接
建立链接:$mysqli = new mysqli('localhost','数据库用户名','密码','库名');
设置编码:$mysqli -> set_charset('utf8');
增加:$res = $mysqli -> query('insert into user (user_name,user_password) values ("admin","123123")');
修改:$res = $mysqli->query('update user set user_password = "111" where user_id = 1');
删除:$res = $mysqli->query('delete from user where user_id = 1');
查询: $res = $mysqli->query('select * from user where user_id = 1')