PHP implementation of MySQL update record code _php tutorial

Source: Internet
Author: User
Tags mysql update administrator password
First comb the operation idea:

List all data
Select the data record you want to modify and enter the editable state.
Submit Modification Results Complete modification
Lists the data view.php in the database and adds a modify before each record so that the user can select the records they want to modify.
Copy CodeThe code is as follows:
$link =mysql_connect ("localhost", "root", "Administrator Password");
mysql_select_db ("Infosystem", $link);
$q = "SELECT * from Info";
mysql_query ("SET NAMES GB2312");
$rs = mysql_query ($q, $link);

echo "


"; echo " "; while ($row = Mysql_fetch_row ($rs)) echo " "; echo "
Department Name Employee Name PC Name
Modify $row [1] $row [2] $row [3] $row [4] $row [5] $row [6] $row [7] $row [8] $row [9] $row [10] $row [11] $row [12] $row [13]
";
?>



When the user clicks Modify, enter the editable state of the corresponding record modify_do.php:

Copy CodeThe code is as follows:

$link =mysql_connect ("localhost", "root", "Administrator Password");
if (! $link) {die ("error");}
echo "Connect MySQL successfully";
mysql_select_db ("Infosystem", $link);
$del _id=$_get["id"];
$q = "SELECT * from info where id= $del _id";

mysql_query ("SET NAMES GB2312"); Code Conversion
$rs = mysql_query ($q, $link);
if (! $rs) {die ("No results Displayed");}
?>










Finally, process the commit data modify_finish.php:

Copy CodeThe code is as follows:

$link =mysql_connect ("localhost", "root", "Administrator Password");
if (! $link) {die ("error");}
echo "Connect MySQL successfully";
mysql_select_db ("Infosystem", $link);

mysql_query ("SET NAMES GB2312");

$rs = mysql_query ($q, $link);
$row = Mysql_fetch_object ($RS);
$exec = "Update info set ename= '". $_post[' ename ']. "' Where id= '. $_post[' id ']." "; Modify the data and add the last update time

echo "modified successfully!";

Mysql_close ($link); To close a data set

?>

Author: Sunec
Original download: Cenus Blog
All rights reserved. The author and original source and this statement must be indicated in the form of a link in the reprint.

http://www.bkjia.com/PHPjc/319134.html www.bkjia.com true http://www.bkjia.com/PHPjc/319134.html techarticle first comb The operation idea: List all data selection needs to modify the data record, enter the editable state. Submit modification Results Complete modification first lists data in the database view ....

  • 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.