Details about adding, deleting, modifying, and querying php instances

Source: Internet
Author: User
1. Add insert. phphtmlheadbodyformactiondoinsert. phpmethodPOSTpID: brinputtypetextnameidsize6maxlength6pp and set a name for yourself.

1 add 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: br/input type = "text" name = "name" size = "10" maxlength = "10" // p

1 increase

Insert. php








Doinsert. php


$ LinkID = @ mysql_connect ("localhost", "root", "123456 ");
If (! $ LinkID ){
Echo "no connection ";
}
$ Ss = @ mysql_select_db ("bean ");
If (! $ Ss ){
Echo "no database found ";
}
$ 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 =' $ mapp '";

$ Result = mysql_query ($ query );

If ($ result) echo"

Member successfuly insert!

";
Else echo"

There was a problem inserting the member!

";

Mysql_close ();
Include "insert. php" // return and continue to insert
?>

2. query and modify

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 "failed ";
}
// 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!

";
Else echo"

There was a problem updating the member!

";

Mysql_close ();
?>

3. Delete multiple objects

Eform. php check box







Deleteform1.php multi-choice drop-down list








Delete. php traversal array Deletion

$ LinkID = @ mysql_connect ("localhost", "root", "123456 ");
$ Db = @ mysql_select_db ("bean ");
// Echo $ _ POST ['kk '];
// Echo array ('1', '2', '3 ');
Foreach ($ _ POST ['kk '] as $ pp) // traverses the array and assigns a value to each
{
Echo $ pp;
$ RowID = $ pp;
$ Query = "delete from member3 where id = '$ rowid'"; // query statement
$ Result = mysql_query ($ query); // put it to the database for execution

If (! Mysql_affected_rows () = 0)
Echo"

The selected item ". $ rowID." has been deleted successfully!

";

If (mysql_affected_rows () = 0 ){
Echo"

No record found!

";
}
}


?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.