Use thinkPHP to update data: [Original] and thinkphp. Using thinkPHP to update data: an example [original]. using thinkphp, we deleted and deleted data in batches in the previous article, in this article, we will update data and use thinkPHP to update data: [Original] and thinkphp.
In the previous article, we deleted and deleted data in batches. in this article, we will update the data.
The first is expectation:
After clicking the Modify button, enter the modi.html page and modify it. in this case, the attribute of real name is modified:
Click save:
The above is the implementation result. the specific code is as follows:
First, the code in the view is still:
User name:
Real name:
Mobile phone number:
Email:
Time added:
Set password:
Confirm password:
Save
Next is the controller: it should be noted that the value before modification needs to be written here, mainly to facilitate user memo, so you need to make an if branch judgment:
Public function modi () {if (IS_POST) {$ adminUsersModel = D ("adminUsers"); $ adminUsersModel-> create (); // var_dump ($ adminUsersModel ); // exit ("created successfully! "); If ($ adminUsersModel-> save () {$ this-> success (" modified successfully ", U (" Admin/User/lists "));} else {$ this-> error ($ adminUsersModel-> getError () ;}} else {$ id = isset ($ _ GET ['id'])? Intval ($ _ GET ['id']): ''; if ($ id ='') {exit ("bad param! Enter id ") ;}$ adminUsersModel = D (" adminUsers "); $ adminUsers = $ adminUsersModel-> find ($ id); // var_dump ($ adminUsers ); $ this-> assign ("adminUsers", $ adminUsers); $ this-> display ();}}
This article is original to the blogger. For more information, add the original website.
Link thinkPHP Reference Manual: http://document.thinkphp1.cn/manual_3_2.html
Digress: Recently, I was very busy. I didn't know how to go to the garden except to check something. today, I went online and found that the garden was not as busy as before. I was a little lost, I don't know what park friends think. anyway, I think that in such a very noisy social environment, I can find a person like garden who can calm down and write a few lines of code, there are not many places to think about life. I hope you can support such a platform and share more things. As a junior, I hope to receive more help from you.
In the previous article, we deleted and deleted data in batches. in this article, we will update the data...