test 表,字段就两 username,password,其他的类似 俺的水平很有限,自己将就看看吧, PHP: $db_host = "localhost"; // 数据库服务器 'localhost' $db_user = "root"; //mysql用户名 $db_pass = "pass"; //mysql 密码 $db_name = "test"; //数据库名称 $db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); PHP: //读取 $sql = "SELECT * FROM test "; $result = mysql_query($sql); while($r=mysql_fetch_array($result)) { $_Username=$r["username"]; $_Password=$r["password"]; echo $_Username."<br />"; //output } PHP: //添加,自己做个表单传递参数 $username=$_POST['username']; $password=$_POST['password']; $sql ="INSERT into test (username,password) VALUES ('$username','$password')"; mysql_query($sql) or die(mysql_error()); echo "添加成功"; PHP: //删除 //传递一个参数 $username=$_GET['username']; $sql = "DELETE FROM test WHERE username = '$username'"; mysql_query($sql) or die(mysql_error()); echo "删除成功"; PHP: //更新 //获取参数 $username=$_POST['username']; $password=$_POST['password']; $sql = "UPDATE test SET username='$username', password='$password' WHERE username= '$_POST['username']'"; mysql_query($sql) or die(mysql_error()); echo "修改成功"