This example shows the customer information in the customer information table. After batch deletion, the user displays the page code sdel.html to dynamically obtain the user information: & lt; formaction & quot ;__ URL _/sdelete/& quot; method & quot; post...
In this example, the customer information of the customer information table is deleted. First, the user displays the page code sdel.html to dynamically obtain the user information:
-
-
-
- Customer ID
- Customer store name
- Customer name
- Customer phone number
- Customer address
- Select
-
-
-
- {$ Khxx. id}
- {$ Khxx. name}
- {$ Khxx. cname}
- {$ Khxx. tel}
- {$ Khxx. address}
-
- // Note that the user ID transmitted to the delete page is hidden.
-
-
- {$ Page}
-
Delete method sdelete ()
- ? Function sdelete (){
-
- $ User = M ('customer'); // instantiate the model
- If ($ data = $ user-> create () {// create a data object
- $ Data = array_pop ($ data); // Convert the obtained two-dimensional array to one-dimensional array.
- $ List = ""; // instantiate the parameter to be deleted
- $ Max = count ($ data)-1; // extract the array length to prepare a loop
- For ($ I = 0; $ I <= $ max; $ I ++) {// cyclically extract an array
- If ($ I! = $ Max) {// if it is not the last value of the array, a comma (,) is added. otherwise, no separator is added and a loop is introduced. $ List
- $ List = $ list. $ data [$ I]. ',';
- } Else {
- $ List = $ list. $ data [$ I];
- }
- }
- If ($ user-> where ('Id in ('. $ list. ')-> delete () {// delete a data record. SQL = delete * from customer where id in ($ list );
- $ This-> success ('deleted successfully ');
- } Else {
- $ This-> error ('deletion failed ');
- }
- } Else {
- $ This-> error ('verification failed ');
- }
- }