PHP+mysql+html 创建电话本 实现增删改查
一、建表 (这里表名为“telephone”)
二、连库
<?php
$conn = mysqli_connect('localhost','root','root','exercise');
if(!$conn){
echo mysqli_error();
}
?>
三、各页面控制
all.php(首页面 /管理页面)
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>电话本</title>
<style type="text/css">
body{
padding:50px;
}
a{
padding:10px;
color:black;
text-decoration:none;
font-size:20px;
background-color:#F2F2F2;
margin:40px;
}
table{
margin:50px;
}
</style>
</head>
<body>
<a href="phone_add.php">添加联系人</a>
<?php
header('content-type:text/html;charset=utf-8');
require_once ('connect.php');
function showTable($conn,$table_name){
$sel = "select * from telephone";
$query &