php 原生mysqli

header("Content-type:text/html; charset=utf-8");
$con = mysqli_connect("localhost", "root", "root");
$arr = array("刘新平","迟磊","李迪","耿建明","苏晓歌","程春林","王红婧","张栋良","胡巍","张士军","邹鹏","刘菲菲","王辉","李冬","贾莹","李丽","李梦娇","郑立杰","马奕然","吴长梅","王欢","白玉琳","马建全","杨永惠","刘舰","滕悦","马召安","李神引","杜胜利","李荣敏","刘建明","张培民","谷雪","杨明霖","张楠","卢艳","郑齐");

mysqli_query($con, "set names utf8");
mysqli_select_db($con, "bss");
mysqli_set_charset($con, "utf-8") ;
foreach($arr as $val){
$sql = "insert into `salesman` set name= '".$val."'";
mysqli_query($con, $sql);
}

上一篇:html声明charset="utf-8"后,浏览器访问中文依旧乱码(绝对有效)


下一篇:MySQL数据库---库的操作