1增 insert.php html head /head body form action="doinsert.php" method="POST" p ID:br/ input type="text" name="id" size="6" maxlength="6" / /p p 给自己起一个名号:br/ input type="text" name="name" size="10" maxlength="10" / /p p 给自己设一个
1增
insert.php
doinsert.php
$linkID=@mysql_connect("localhost","root","123456");
if(!$linkID){
echo "没连接上";
}
$ss=@mysql_select_db("bean");
if(!$ss){
echo "没找到数据库";
}
$id = $_POST['id'];
$name = $_POST['name'];
$password = $_POST['password'];
$email = $_POST['email'];
$query = "INSERT INTO member3 (id,name,password,email) values(
'$id','$name','$password','$email')";
//$query = "insert into member3 set
// id='$id',name='$name',password='$password',email='$email'";
$result = mysql_query($query);
if($result) echo "
member successfuly insert!
";There was a problem inserting the member!
";2查询并且修改
form.php
modify.php
$linkID=@mysql_connect("localhost","root","123456");
$ss=@mysql_select_db("bean");
$rowID = $_POST['rowID'];
$query="select id ,name,password,email from member3 where id='$rowID'";
$result=mysql_query($query);
if(!$result){
echo "没执行成功";
}
//echo "$result";
list($id,$name,$password,$email)=mysql_fetch_row($result);
//echo "$id";
//echo "$name";
//echo "$password";
//echo "$email";
mysql_close();
include "modifyform.php";
?>
modifyform.php
update.php
$linkID=@mysql_connect("localhost","root","123456");
$db=@mysql_select_db("bean");
$rowID=$_POST['rowID'];
$id=$_POST['id'];
$name=$_POST['name'];
$password=$_POST['password'];
$email=$_POST['email'];
//echo $rowID;
$query=" UPDATE member3 SET id='$id',name='$name',password='$password',email='$email'where id='$rowID' ";
//echo $query;
$result=mysql_query($query);
if($result) echo "
member successfuly update!
";There was a problem updating the member!
";3删除 多选删除
deleteform.php 复选框
deleteform1.php 多选下拉列表
delete.php 遍历数组删除
$linkID=@mysql_connect("localhost","root","123456");
$db=@mysql_select_db("bean");
//echo $_POST['kk'];
//echo array('1','2','3');
foreach($_POST['kk'] as $pp)//遍历数组,给每个赋值
{
echo $pp;
$rowID=$pp;
$query="delete from member3 where id='$rowID'";//查询语句
$result=mysql_query($query);//放到数据库执行
if(!mysql_affected_rows()==0)
echo "
选择的项".$rowID."已经成功的被删除!
" ;没有找到记录!
" ;