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

 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();

 

posted @ 2018-06-27 09:43  撑一支船蒿  阅读(995)  评论(0编辑  收藏  举报