通过mysqli读取数据

<?php

	$mysqli = new mysqli("localhost", "user", "******", "dbtest");

	if (mysqli_connect_errno()) 
	{
		printf("Connect failed: %s\n", mysqli_connect_error());
		exit();
	}else
	{
		printf("Connect succeed");
	}

	printf("<br>");
	
	$query = "select * from tabletest";
	$result= $mysqli->query($query);  
	if($result)
	{
		if($result->num_rows>0)
		{                          
			while($row =$result->fetch_array() )
			{             
				echo ($row[0])."<br>";  
				echo ($row[1])."<br>";  
				echo "<hr>";  
			}  
		}
	}else
	{
		echo "查询失败";
	}

	$result->free(); 
	$mysqli->close();
?>

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页