欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

php5.4以上 mysqli 实例操作mysql 增,删,改,查

程序员文章站 2022-06-20 08:46:03
1 query('set names utf8'); 7 $sql_search = "select * from bb where id=9"; 8 /*$sql_add = "insert into bb(name) values ('小明')"; 9 $sql_update = "update... ......
 1 <?php
 2 //php5.4以上 mysqli 实例操作mysql
 3 header("Content-type:text/html;charset=utf8");
 4 $conn = new mysqli('localhost', 'root', 'root');
 5 mysqli_select_db($conn, 'cc');
 6 $conn->query('set names utf8');
 7 $sql_search = "select * from bb where id=9";
 8 /*$sql_add = "insert into bb(name) values ('小明')";
 9 $sql_update = "update bb set name = '小h' where id=9";
10 $sql_del = "delete from bb  where id=9";*/
11 $result = $conn->query($sql_search);
12 while ($row = $result->fetch_array()) {
13     echo $row['name'] . '<br/>';
14 }
15 $conn->close();