在navicat上创建student库,下面创建info表,表内填写信息id和name字段
用phpstorm连接数据库并展示信息
//连接数据库
$con = mysqli_connect("localhost", "root", "root", "student", "8888");
if (mysqli_connect_error($con)) {
echo "连接失败" . mysqli_connect_error();
} else
echo "连接成功";
//查找操作
$q = "select * from info";
//添加、插进用户信息
//mysqli_query($con, "insert into info(id,name ) value (1006,heihei)");
$result = $con->query($q);
while ($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"] . " - Name: " . $row["name"] . "";
}
mysqli_close($con) ?>
浏览器中展示的效果
|