php + MySQL actual cases [seven] data editing, deleting

This section explains the user information and delete users modify the user management module.

Modify user information:

You can edit user record selection, you can modify the user name, password, gender, phone, email and address information.

Delete User Information:

The list of specified user delete operation.

 

Second, edit user information

Edit user information:

Select one of the logs in the list will be diverted to the transfer Id record edit page when you click Edit. Id according to the edit page which records information query, the results to fill the edit form. When you click Save, information collection form after delivery to the user to edit PHP to update the contents of the database table. Workflow See the following figure:

 

 

Key Code:

Id passed to the editor page when you click Edit:

           

function Edit(Id){

                x_admin_show("编辑","member-edit.php?Id="+Id,400,600);

            }

Editing interface for data query and results are filled according to the edit form Id:

$.ajax({

                        url: "action/GetUserById.php", 

                        dataType: "json", 

                        async: true,

                        data:{

                            Id:Id

                        },

                        type: "POST", // request method

                        success: function (req) {

                           if (req.length>0) {

                            $("#Id").val(req[0].Id);

                            $("#username").val(req[0].username);

                            $("#password").val(req[0].password);

                            $("#sex").val(req[0].sex);

                            $("#email").val(req[0].email);

                            $("#phone").val(req[0].phone_number);

                            $("#address").val(req[0].address);

                           }

                        },

                        error: function () {

                            alert ( "Data Request Interface Error!");

                        }

             

                    });

After editing and saving the user:

function save(){

            //alert($('#EditFrom').serialize());

            $.ajax({

                    url: "action/UpdateUserById.php", 

                    //dataType: "json", 

                    async: true,

                    data: $ ( '# EditFrom') serialize (), // the value sequence of the form submission as a parameter. 

                    type: "POST", // request method

                    success: function (req) {

                        if (req=='200') {

                            alert ( "Saved!");

                            var index = parent.layer.getFrameIndex (window.name); // Get subpage index

                            parent.layer.close (index); // close the sub-pages

                            parent.location.reload (); // refresh the parent page

                        }else{

                            alert ( "save failed!");

                        }

                    },

                    error: function () {

                        alert ( "Data Request Interface Error!");

                    }

         

                });

          }

 Third, delete user information

Delete User Information:

In the list select a record for deletion, the transfer Id recorded a charge of PHP to delete user information, the user specifies the Id of records deleted from the database side. Workflow See the following figure:

 

Key Code

According Id delete user information:

function Delete(Id){

                $.ajax({

                        url: "action/DelUserById.php", 

                        //dataType: "json", 

                        async: true,

                        data:{

                            Id:Id

                        },

                        type: "POST", // request method

                        success: function (req) {

                           if (req=='200') {

                            alert ( "Deleted!");

                            location.reload (); // refresh the current page

                        }else{

                            alert ( "Delete failed!");

                        }

                        },

                        error: function () {

                            alert ( "Data Request Interface Error!");

                        }

             

                    });

            }

Follow-up

php + MySQL actual cases [8] registered users

 

 

 

 Micro-channel public number synchronized.

Guess you like

Origin www.cnblogs.com/soulsjie/p/12666877.html