php数据库的连接
<?php
$con = new mysqli(‘localhost‘,‘root‘,‘root‘,‘edu‘);//地址,账户,密码,edu代表的数据库
// $sql=‘insert into grade (name,tid) values("a","2")‘;
$sql=‘select * from grade‘;
$rel=$con->query($sql);
$data = $rel->fetch_all(MYSQLI_ASSOC);
// $data1 = $rel->fetch_assoc();
// $data2 = $rel->fetch_assoc();
// var_dump($data);
// var_dump($data1);
// var_dump($data2);
foreach($data as $val){
echo $val[‘name‘].‘<br>‘;
}
if($con->connect_error){
die(‘连接失败‘.$con->connect_error);
}
echo ‘连接成功‘;
$con->close();
?>
die的意思代表执行后关闭。其他的都是些死记硬背的。
相关推荐
zyyjay 2020-11-09
xuebingnan 2020-11-05
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28
diskingchuan 2020-10-23
savorTheFlavor 2020-10-23