标签:
1 代码: 2 //1.得到mysqli连接 3 header("Content-type: text/html;charset=utf-8"); 4 $mysqli=mysqli_connect("localhost","root","root","test"); 5 if(!$mysqli){ 6 die("连接失败".mysqli_connnect_error($mysqli)); 7 } 8 //2.向数据库发送sql语句(ddl,dml dql ...) 9 $sql="select * from user1"; 10 $res=mysqli_query($mysqli,$sql); 11 //var_dump($res); 12 //3.处理得到的结果 13 //循环取出$res中的数据mysqli_fetch_row mysql_fetch_row 14 while($row=mysqli_fetch_row($res)){ 15 16 foreach($row as $key=>$val){ 17 echo "--$val"; 18 } 19 echo "<br/>"; 20 } 21 //4.关闭资源 22 mysqli_free_result($res); 23 mysqli_close($mysqli);
标签:
原文地址:http://www.cnblogs.com/zzg521/p/4204644.html