Difeye是一款超轻量级PHP框架,主要特点有: Difeye是一款超轻量级PHP框架,主要特点有: ◆数据库连接做自动主从读写分离配置,适合单机和分布式站点部署; ◆支持Smarty模板机制,可灵活配置第三方缓存组件; ◆完全分离页面和动作,仿C#页面加载自动执行Page_Load入口函数; ◆支持mysql,mongodb等第三方数据库模块,支持读写分离,分布式部署; ◆增加后台管理开发示例
<?php$link = mysqli_connect("localhost","root","root") ordie("Connect error");
if($link){
echo"Connect success<br>";
mysqli_select_db($link, "world");
$sql = "select * from city";
$result = mysqli_query($link, $sql);
$rows = mysqli_num_rows($result);
$cols = mysqli_num_fields($result);
echo"rows are ".$rows.", cols are ".$cols."<br>";
echo"<table border='1' align='center' width='80%'>";
echo"<caption>City info</caption>";
echo"<th>ID</th><th>Name</th><th>CountryCode</th><th>District</th><th>Population</th>";
while ($row=mysqli_fetch_row($result)){
echo"<tr align='center'>";
foreach ($rowas$data){
echo"<td>".$data."</td>";
}
echo"</tr>";
}
echo"</table>";
}else {
echo"Connect error";
}
?>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了PHP连接数据库并读取数据打印,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。










