码迷,mamicode.com
首页 > Web开发 > 详细

php练习1

时间:2016-08-01 15:52:51      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

<?php
$conn=mysqli_init();
if(!conn){
echo "mysqli_init error";
exit(0);
}
$ret=mysqli_real_connect($conn,"localhost","root","123456","test2",3306,MYSQL_CLIENT_FOUND_ROWS);
if(!$ret){
echo "mysqli_real_connect error!";
exit(0);
}
//插入记录

/*
$sql=‘insert into test values(1,"tom")‘;
$ret=mysqli_query($conn, $sql);
if(!$ret){
echo "myslqi_query error!";
exit(0);
}
*/
//查询记录
$sql="select * from test";
$ret=mysqli_query($conn, $sql);
//获取查询结果
while(($row=mysqli_fetch_array($ret,MYSQLI_ASSOC))!=NULL){
echo "id: " . $row[‘id‘] . "<br>";
echo "name: " . $row[‘name‘] . "<br>";
}
?>

php练习1

标签:

原文地址:http://www.cnblogs.com/lykouyi/p/5725903.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!