The example of this article describes the Php+ajax simple implementation of the total selection of deletion method. Share to everyone for your reference, specific as follows:
<input type= "checkbox" id= "Ckb_selectall" onclick= "SelectAll ()" title= "Check/uncheck" >
<a href= "javascript: void (0); "onclick=" Del_ () title= "Delete selected data" style= "font-weight:normal" > Delete </a>
↑ All Select checkbox
<input type= "checkbox" class= "ckb" id= "+con.id+" value= "+con.id+" >
↑ for deletion item, the same name class is CKB, convenient to operate, at the same time the ID value cleverly put into input, easy to obtain.
function SelectAll () {
if ($ (' #ckb_selectAll '). Is (': Checked ') {
$ (". ckb"). attr ("Checked", true);//All selected
} else {
$ (". ckb"). attr ("checked", false);//Cancel All
}
}
↑ Selected Events
function Del_ () {
var ids = ';
$ (". ckb"). each (the function () {
if ($ (). Is (': Checked ')) {
ids + = ', ' + $ (this). Val ();//Get ID one by one
}
});
ids = ids.substring (1); The ID is processed to remove the first comma
if (ids.length = 0) {
alert (' Please select the option to delete ');
} else {
If confirm ("OK delete?"). You will not be able to recover after deletion. ")" {
URL = "action=del_call_record&ids=" + IDs;
$.ajax ({
type: "Post",
URL: "send.php",
Data:url,
success:function (JSON) {
if parseint ( Json.counts) > 0) {
alert (json.des);
Location.reload ();
} else {
alert (json.des);
}
},
error:function (XMLHttpRequest, textstatus) {
alert ("Page request error, Please check to try again or contact admin! \ n "+ Textstatus);}}";}}
↑ Delete with Ajax to process.
↓ Background operation database, processing delete action.
$ids = Trim ($_request[' IDs ']);
$del _sql = "DELETE from Vicidial_call_record WHERE ID in (". $ids. ");
Print_r ($del _sql); exit;
if (Mysqli_query ($db _conn, $del _sql)) {
$counts = "1";
$des = "Success";
} else {
$counts = "0";
$des = "Failed";
}
$json _data = "{";
$json _data. = "\" counts\ ":". Json_encode ($counts). ",";
$json _data. = "\" des\ ":". Json_encode ($des). "";
$json _data. = "}";
echo $json _data;
Break
Complete
For more information about PHP interested readers can view the site topics: "Php+ajax Skills and Application Summary", "PHP Network Programming Skills Summary", "PHP object-oriented Program Design Introduction Tutorial", "PHP string (String) Usage Summary", "php+ MySQL Database operations Introduction tutorial and PHP Common database operation Skills Summary
I hope this article will help you with the PHP program design.