First, in the article List page (list.php), the multi-select basket is named: "$del _id[]", the value is the article ID number. For example (list.php):
- < form name = ' Del_form ' action = ' del.php '
method=' post '>
- < ? PHP
- $ result = mysql_query (' SELECT * from News ');
- While ($rs=mysql_fetch_array($result)) {
- ?>
- < input name=' del_id[] ' type =' checkbox '
ID=' del_id[] ' value=' <? = $rs [id] ?> ' />
- < ? = $rs [title] ?>
- < ? PHP
- }
- ?>
- < /form >
- 2. Processing page (del.php):
- < ? PHP
- if ($del _id!= ") {
- $ Del_num = Count ($del _id);
- For ($i=0; $i< $del _num; $i + +) {
- mysql_query (' Delete from news where
ID=' $del _id[$i] ');
- }
- Echo ('< script type=' text/ JavaScript '>
alert (' Delete succeeded! '); History.back (); < /script > ');
- }else{
- Echo ('< script type=' text/javascript ') >
alert (' Please select item first! '); History.back (); < /script > ');
- }
- ?>
1.PHP Bulk Delete Data first introduces jquery script library
- <scriptlanguage=' JavaScript '
type = ' Text/javascript '
src = ' Http://jqueryjs.googlecode.
Com/files/jquery-1.3.2.min.js '>
- < /script >
Add the following code
- < script language=' JavaScript '
type = ' Text/javascript ' >
- $ (document). Ready (function ()
- {
- $ (' input[id=' del '] '). Click (function ()
- {
- var Del_arry = '' ;
- $ (' input[name=' del_id[] '][checked] ')
. each (function () {
- Del_arry Del_arry =del_arry+$ (This). Val () + ', ';
- });
- if (del_arry!= ")
- {
- $.post (' com_del.php ', {value: ' +
del_arry+ '}, function (data) {
- if (data==1) {
- Window.location.reload ();
- Alert (' Delete succeeded! ');
- }else if (data==2) {
- Alert (' Delete failed! ');
- }
- });
- }
- });
- });
- < /script >
2.com_shen.php(The following sections can be played on their own, using your own database connection and processing methods)
- < ? PHP
- Include '. /cyr/inc/conn.php ';
- Include '. /cyr/inc/page.class.php ';
- $ Conn = New DB ();
- $conn- > Connection ();
- $ Array = $_post[' value '];
- Puts an array of the selected values into the $array array
- $ Array = Split (', ', $array);
- if (!empty ($array)) {
- $ Del_num = Count ($array);
- For ($II=0; $ii< $del _num; $ii + +) {
- $conn- > Str = ' Update yj_comment set
co_shenhe=1 where id= '. $array [$ii];
- $conn- > GetResult ();
- }
- echo $ string = 1 ;
- }else{
- echo $ string = 2 ;
- }
- $conn- > colseconnection ();
- ?>
The above is the PHP bulk delete data related implementation method.
http://www.bkjia.com/PHPjc/445963.html www.bkjia.com true http://www.bkjia.com/PHPjc/445963.html techarticle first, in the article List page (list.php), the multi-select basket is named: $del _id[], the value is the article ID number. For example (list.php): Form name = ' del_form ' action = ' del.php ' method = ' post '? PHP $ re ...