时间:2021-07-01 10:21:17 帮助过:16人阅读
<?= MySQLi("localhost","root","12345678","heiheihei" = "select * from student" = ->query(( = -> (?>
最后的返回值是一个集对象,为了方便清晰的看到结果 我们用到了fetch_all(),fetch_row(); fetch_object();
//造连接对象$db = new MySQLi("localhost","root","12345678","heiheihei");//准备SQL语句$sql = "insert into cou values(‘3-111‘,‘嘿嘿‘,‘803‘)"; //执行SQL语句$r = $db ->query($sql);if($r)//如果$r是ture{ echo "执行成功"; }else { echo "执行失败"; }
<?php//造连接对象$db = new MySQLi("localhost","root","12345678","heiheihei");//准备SQL语句$sql = "update cou set cname=‘哈哈‘ where tno=‘803‘"; //执行SQL语句$r = $db ->query($sql);if($r) { echo "执行成功"; }else { echo "执行失败"; }?>
<?php//造连接对象$db = new MySQLi("localhost","root","12345678","heiheihei");//准备SQL语句$sql = "delete from cou where tno=‘803‘"; //执行SQL语句$r = $db ->query($sql);if($r) { echo "执行成功"; }else { echo "执行失败"; }?>
php连接mysql数据库
标签:php连接mysql数据库