PHP连接数据库并读取数据打印
程序员文章站
2022-04-30 21:55:55
...
$link = mysqli_connect("localhost","root","root") ordie("Connect error");
if($link){
echo"Connect success
";
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."
";
echo"";
echo"City info ";
echo"ID
Name
CountryCode
District
Population ";
while ($row=mysqli_fetch_row($result)){
echo"";
foreach ($rowas$data){
echo"".$data."
";
}
echo"
";
}
echo"
";
}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教程有兴趣的朋友有所帮助。