参考资料来自,菜鸟网语法教程:http://www.runoob.com/php/php-mysql-insert.html。当然是自己动手敲了
代码:
<?php
//连接参数
$path="localhost";
$name="root";
$password="";
$db_name="leaving_message";
//连接库
$connect=new mysqli($path,$name,$password,$db_name);
//判断是否连接成功
if ($connect->connect_error) {
echo "connect_Error";
}
//拼写SQL语句、
$sql="select * from message where state=0";
//执行查询语句,结果记录集交给变量存储
$result=$connect->query($sql);
//判断返回的记录集是否>0,判断查出数据没有
if($result->num_rows > 0){
//循环取数据,通过fetch_assoc()函数,从记录集变量result中取出数据
while($row=$result->fetch_assoc()){
//在echo输出 打上.点,可以一次写在一行输出,取数据中的字段
//fetch_assoc取出记录集,echo $row测试报错,信息含有Array数组关键字?,我以为取出的一行,所以打印row行记录
//从fetch_assoc接收得出的数据给row,从row变量中,参数列字段,返回单元格结果
echo $row["text"] ." " .$row["ctime"];
echo "<br/>";
}
}else{
echo "select_Null";
}
//关闭连接
$connect->close();
?>