Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHP使用checkbox从mysql数据库中删除多行?_Php_Mysql_Checkbox_Delete Row_Isset - Fatal编程技术网

如何使用PHP使用checkbox从mysql数据库中删除多行?

如何使用PHP使用checkbox从mysql数据库中删除多行?,php,mysql,checkbox,delete-row,isset,Php,Mysql,Checkbox,Delete Row,Isset,我试图在“管理员”数据库中删除我的数据,但删除按钮不起作用 这是我最重要的部分 <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="admin"; // Database name $tbl_name="admin"; // Table name // Connect to server and sel

我试图在“管理员”数据库中删除我的数据,但删除按钮不起作用

这是我最重要的部分

<?php
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="admin"; // Database name 
$tbl_name="admin"; // Table name 
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>

这是我的复选框代码

<tbody>
<?php
    while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><?php echo $rows['course_code']; ?></td>
<td><?php echo $rows['course_name']; ?></td>
<td><?php echo $rows['lecture_id']; ?></td>
<td><input name="checkbox[]" type="checkbox"
    id="checkbox[]" value="<?php echo $rows['course_code'];?>"></td>
<td><form>
</form>
</td>
</tr>
<?php
    }
?>
</tbody>


包括
标记中的所有输入元素:
所有输入都在这里

更新:

<input name = "checkbox[]" type="checkbox"  id="checkbox[]" value="<?php echo     $rows['course_code'];?>">

包括
标记中的所有输入元素:
所有输入都在这里

更新:

<input name = "checkbox[]" type="checkbox"  id="checkbox[]" value="<?php echo     $rows['course_code'];?>">

试试这段代码。它运行良好。
connection.php

<?php $hostname_conection = "localhost"; /* this is the server name(assigned to variable) which is localhost since it runs on local machine */ 
$database_conection = "company"; /* this is the database name( assigned to variable)*/ 
$username_conection = "root"; /* user name (assigned to variable)*/
$password_conection = ""; /*password (assigned to variable) */ 
$conection = mysql_connect($hostname_conection, $username_conection, $password_conection) or trigger_error(mysql_error(),E_USER_ERROR); /* Mysql_connect function is used to conncet with database it takes three parameters server/hostname, username,and password*/ 
mysql_select_db($database_conection,$conection) or die(mysql_error("could not connect to database!")); /* Mysql_select is used to select the database it takes two parameters databasename and connection variable in this case $conection */ 
?>
<?php require_once('conection.php'); ?> 
<?php 
in
/* now to display the data from the database which we inserted in above form we */ /* we make the query to select data from the table EMP */ 
            $display = "select * from test_mysql";
        $result = mysql_query($display, $conection) or die(mysql_error()); /* the query is executed and result of the query is stored in variable $result */ 
        if ($result == FALSE) {
            die(mysql_error()); /* displays error */
        } ?> <h1 align="center"> Displaying Recods in Table </h1> 
        <form method="get" action="" id="deleteform" > 
            <table width="245" border="1" align="center"> 
                <tr>
                    <td width="51">
                        <input type="submit" name="delete" id="button" value="delete" onclick="document.getElementById('deleteform').action = 'delete.php';document.getElementById('deleteform').submit();"/> <!--- here on clicking the button the form is submitted and action is set to delete.php Here we have used javaScript document refers to this whole page and now we can access any tag that has its id with help of getElementById() method and after the we specify the operation we want to perform in this case action and submit. ---> 
                    </td> 
                    <td width="50">id</td> 
                    <td width="55">name</td>
                    <td width="47">lastname</td>
                </tr>
 <?php 
 while ($rows = mysql_fetch_array($result)) 
        { /* here we make use of the while loop which fetch the data from the $result int array form and stores in $row now we can display each field from the table with $row[‘field_name’] as below */ 
     ?> 
                <tr>
                    <td>
                        <input type="checkbox" name="empids[]" value="<?php echo $rows['id']; ?>" /> <!--here with each checkbox we send the id of the record in the empids[] array ---> 
                    </td>
                    <td>
                        <?php echo $rows['id'] ?>
                    </td>
                        <td>
                            <?php echo $rows['lastname'] ?>
                        </td>
                        <td><?php echo $rows['name'] ?></td> 
                            <?php } ?>
                </tr>
            </table>
        </form> ?>
    </body>
</html>
<?php 
require_once('conection.php'); 
?>
 <?php
 if (isset($_GET['delete'])) /* checks weather $_GET['delete'] is set*/
     {
     if (isset($_GET['empids'])) /* checks weather $_GET['empids'] is set */ 
         { 
         $checkbox = $_GET['empids']; /* value is stored in $checbox variable */ 
         if (is_array($checkbox)) 
             { 
             foreach ($checkbox as $key => $your_slected_id) /* for each loop is used to get id and that id is used to delete the record below */ 
                 { 
                 $q="DELETE FROM test_mysql WHERE id=$your_slected_id "; /* Sql query to delete the records whose id is equal to $your_slected_id */
                 mysql_query($q,$conection) ; /* runs the query */ 

                 } 
                 header("location:multiple_delete.php"); /* Goes back to index.php */ 

                 } 

                 } else 
                     { 
                     echo" you have not selected reords .. to delete"; 

                     } 

                     } ?>

multiple_delete.php

<?php $hostname_conection = "localhost"; /* this is the server name(assigned to variable) which is localhost since it runs on local machine */ 
$database_conection = "company"; /* this is the database name( assigned to variable)*/ 
$username_conection = "root"; /* user name (assigned to variable)*/
$password_conection = ""; /*password (assigned to variable) */ 
$conection = mysql_connect($hostname_conection, $username_conection, $password_conection) or trigger_error(mysql_error(),E_USER_ERROR); /* Mysql_connect function is used to conncet with database it takes three parameters server/hostname, username,and password*/ 
mysql_select_db($database_conection,$conection) or die(mysql_error("could not connect to database!")); /* Mysql_select is used to select the database it takes two parameters databasename and connection variable in this case $conection */ 
?>
<?php require_once('conection.php'); ?> 
<?php 
in
/* now to display the data from the database which we inserted in above form we */ /* we make the query to select data from the table EMP */ 
            $display = "select * from test_mysql";
        $result = mysql_query($display, $conection) or die(mysql_error()); /* the query is executed and result of the query is stored in variable $result */ 
        if ($result == FALSE) {
            die(mysql_error()); /* displays error */
        } ?> <h1 align="center"> Displaying Recods in Table </h1> 
        <form method="get" action="" id="deleteform" > 
            <table width="245" border="1" align="center"> 
                <tr>
                    <td width="51">
                        <input type="submit" name="delete" id="button" value="delete" onclick="document.getElementById('deleteform').action = 'delete.php';document.getElementById('deleteform').submit();"/> <!--- here on clicking the button the form is submitted and action is set to delete.php Here we have used javaScript document refers to this whole page and now we can access any tag that has its id with help of getElementById() method and after the we specify the operation we want to perform in this case action and submit. ---> 
                    </td> 
                    <td width="50">id</td> 
                    <td width="55">name</td>
                    <td width="47">lastname</td>
                </tr>
 <?php 
 while ($rows = mysql_fetch_array($result)) 
        { /* here we make use of the while loop which fetch the data from the $result int array form and stores in $row now we can display each field from the table with $row[‘field_name’] as below */ 
     ?> 
                <tr>
                    <td>
                        <input type="checkbox" name="empids[]" value="<?php echo $rows['id']; ?>" /> <!--here with each checkbox we send the id of the record in the empids[] array ---> 
                    </td>
                    <td>
                        <?php echo $rows['id'] ?>
                    </td>
                        <td>
                            <?php echo $rows['lastname'] ?>
                        </td>
                        <td><?php echo $rows['name'] ?></td> 
                            <?php } ?>
                </tr>
            </table>
        </form> ?>
    </body>
</html>
<?php 
require_once('conection.php'); 
?>
 <?php
 if (isset($_GET['delete'])) /* checks weather $_GET['delete'] is set*/
     {
     if (isset($_GET['empids'])) /* checks weather $_GET['empids'] is set */ 
         { 
         $checkbox = $_GET['empids']; /* value is stored in $checbox variable */ 
         if (is_array($checkbox)) 
             { 
             foreach ($checkbox as $key => $your_slected_id) /* for each loop is used to get id and that id is used to delete the record below */ 
                 { 
                 $q="DELETE FROM test_mysql WHERE id=$your_slected_id "; /* Sql query to delete the records whose id is equal to $your_slected_id */
                 mysql_query($q,$conection) ; /* runs the query */ 

                 } 
                 header("location:multiple_delete.php"); /* Goes back to index.php */ 

                 } 

                 } else 
                     { 
                     echo" you have not selected reords .. to delete"; 

                     } 

                     } ?>

在表中显示记录
身份证件
名称
姓氏
?>
delete.php

<?php $hostname_conection = "localhost"; /* this is the server name(assigned to variable) which is localhost since it runs on local machine */ 
$database_conection = "company"; /* this is the database name( assigned to variable)*/ 
$username_conection = "root"; /* user name (assigned to variable)*/
$password_conection = ""; /*password (assigned to variable) */ 
$conection = mysql_connect($hostname_conection, $username_conection, $password_conection) or trigger_error(mysql_error(),E_USER_ERROR); /* Mysql_connect function is used to conncet with database it takes three parameters server/hostname, username,and password*/ 
mysql_select_db($database_conection,$conection) or die(mysql_error("could not connect to database!")); /* Mysql_select is used to select the database it takes two parameters databasename and connection variable in this case $conection */ 
?>
<?php require_once('conection.php'); ?> 
<?php 
in
/* now to display the data from the database which we inserted in above form we */ /* we make the query to select data from the table EMP */ 
            $display = "select * from test_mysql";
        $result = mysql_query($display, $conection) or die(mysql_error()); /* the query is executed and result of the query is stored in variable $result */ 
        if ($result == FALSE) {
            die(mysql_error()); /* displays error */
        } ?> <h1 align="center"> Displaying Recods in Table </h1> 
        <form method="get" action="" id="deleteform" > 
            <table width="245" border="1" align="center"> 
                <tr>
                    <td width="51">
                        <input type="submit" name="delete" id="button" value="delete" onclick="document.getElementById('deleteform').action = 'delete.php';document.getElementById('deleteform').submit();"/> <!--- here on clicking the button the form is submitted and action is set to delete.php Here we have used javaScript document refers to this whole page and now we can access any tag that has its id with help of getElementById() method and after the we specify the operation we want to perform in this case action and submit. ---> 
                    </td> 
                    <td width="50">id</td> 
                    <td width="55">name</td>
                    <td width="47">lastname</td>
                </tr>
 <?php 
 while ($rows = mysql_fetch_array($result)) 
        { /* here we make use of the while loop which fetch the data from the $result int array form and stores in $row now we can display each field from the table with $row[‘field_name’] as below */ 
     ?> 
                <tr>
                    <td>
                        <input type="checkbox" name="empids[]" value="<?php echo $rows['id']; ?>" /> <!--here with each checkbox we send the id of the record in the empids[] array ---> 
                    </td>
                    <td>
                        <?php echo $rows['id'] ?>
                    </td>
                        <td>
                            <?php echo $rows['lastname'] ?>
                        </td>
                        <td><?php echo $rows['name'] ?></td> 
                            <?php } ?>
                </tr>
            </table>
        </form> ?>
    </body>
</html>
<?php 
require_once('conection.php'); 
?>
 <?php
 if (isset($_GET['delete'])) /* checks weather $_GET['delete'] is set*/
     {
     if (isset($_GET['empids'])) /* checks weather $_GET['empids'] is set */ 
         { 
         $checkbox = $_GET['empids']; /* value is stored in $checbox variable */ 
         if (is_array($checkbox)) 
             { 
             foreach ($checkbox as $key => $your_slected_id) /* for each loop is used to get id and that id is used to delete the record below */ 
                 { 
                 $q="DELETE FROM test_mysql WHERE id=$your_slected_id "; /* Sql query to delete the records whose id is equal to $your_slected_id */
                 mysql_query($q,$conection) ; /* runs the query */ 

                 } 
                 header("location:multiple_delete.php"); /* Goes back to index.php */ 

                 } 

                 } else 
                     { 
                     echo" you have not selected reords .. to delete"; 

                     } 

                     } ?>

试试这段代码。它运行良好。 connection.php

<?php $hostname_conection = "localhost"; /* this is the server name(assigned to variable) which is localhost since it runs on local machine */ 
$database_conection = "company"; /* this is the database name( assigned to variable)*/ 
$username_conection = "root"; /* user name (assigned to variable)*/
$password_conection = ""; /*password (assigned to variable) */ 
$conection = mysql_connect($hostname_conection, $username_conection, $password_conection) or trigger_error(mysql_error(),E_USER_ERROR); /* Mysql_connect function is used to conncet with database it takes three parameters server/hostname, username,and password*/ 
mysql_select_db($database_conection,$conection) or die(mysql_error("could not connect to database!")); /* Mysql_select is used to select the database it takes two parameters databasename and connection variable in this case $conection */ 
?>
<?php require_once('conection.php'); ?> 
<?php 
in
/* now to display the data from the database which we inserted in above form we */ /* we make the query to select data from the table EMP */ 
            $display = "select * from test_mysql";
        $result = mysql_query($display, $conection) or die(mysql_error()); /* the query is executed and result of the query is stored in variable $result */ 
        if ($result == FALSE) {
            die(mysql_error()); /* displays error */
        } ?> <h1 align="center"> Displaying Recods in Table </h1> 
        <form method="get" action="" id="deleteform" > 
            <table width="245" border="1" align="center"> 
                <tr>
                    <td width="51">
                        <input type="submit" name="delete" id="button" value="delete" onclick="document.getElementById('deleteform').action = 'delete.php';document.getElementById('deleteform').submit();"/> <!--- here on clicking the button the form is submitted and action is set to delete.php Here we have used javaScript document refers to this whole page and now we can access any tag that has its id with help of getElementById() method and after the we specify the operation we want to perform in this case action and submit. ---> 
                    </td> 
                    <td width="50">id</td> 
                    <td width="55">name</td>
                    <td width="47">lastname</td>
                </tr>
 <?php 
 while ($rows = mysql_fetch_array($result)) 
        { /* here we make use of the while loop which fetch the data from the $result int array form and stores in $row now we can display each field from the table with $row[‘field_name’] as below */ 
     ?> 
                <tr>
                    <td>
                        <input type="checkbox" name="empids[]" value="<?php echo $rows['id']; ?>" /> <!--here with each checkbox we send the id of the record in the empids[] array ---> 
                    </td>
                    <td>
                        <?php echo $rows['id'] ?>
                    </td>
                        <td>
                            <?php echo $rows['lastname'] ?>
                        </td>
                        <td><?php echo $rows['name'] ?></td> 
                            <?php } ?>
                </tr>
            </table>
        </form> ?>
    </body>
</html>
<?php 
require_once('conection.php'); 
?>
 <?php
 if (isset($_GET['delete'])) /* checks weather $_GET['delete'] is set*/
     {
     if (isset($_GET['empids'])) /* checks weather $_GET['empids'] is set */ 
         { 
         $checkbox = $_GET['empids']; /* value is stored in $checbox variable */ 
         if (is_array($checkbox)) 
             { 
             foreach ($checkbox as $key => $your_slected_id) /* for each loop is used to get id and that id is used to delete the record below */ 
                 { 
                 $q="DELETE FROM test_mysql WHERE id=$your_slected_id "; /* Sql query to delete the records whose id is equal to $your_slected_id */
                 mysql_query($q,$conection) ; /* runs the query */ 

                 } 
                 header("location:multiple_delete.php"); /* Goes back to index.php */ 

                 } 

                 } else 
                     { 
                     echo" you have not selected reords .. to delete"; 

                     } 

                     } ?>

multiple_delete.php

<?php $hostname_conection = "localhost"; /* this is the server name(assigned to variable) which is localhost since it runs on local machine */ 
$database_conection = "company"; /* this is the database name( assigned to variable)*/ 
$username_conection = "root"; /* user name (assigned to variable)*/
$password_conection = ""; /*password (assigned to variable) */ 
$conection = mysql_connect($hostname_conection, $username_conection, $password_conection) or trigger_error(mysql_error(),E_USER_ERROR); /* Mysql_connect function is used to conncet with database it takes three parameters server/hostname, username,and password*/ 
mysql_select_db($database_conection,$conection) or die(mysql_error("could not connect to database!")); /* Mysql_select is used to select the database it takes two parameters databasename and connection variable in this case $conection */ 
?>
<?php require_once('conection.php'); ?> 
<?php 
in
/* now to display the data from the database which we inserted in above form we */ /* we make the query to select data from the table EMP */ 
            $display = "select * from test_mysql";
        $result = mysql_query($display, $conection) or die(mysql_error()); /* the query is executed and result of the query is stored in variable $result */ 
        if ($result == FALSE) {
            die(mysql_error()); /* displays error */
        } ?> <h1 align="center"> Displaying Recods in Table </h1> 
        <form method="get" action="" id="deleteform" > 
            <table width="245" border="1" align="center"> 
                <tr>
                    <td width="51">
                        <input type="submit" name="delete" id="button" value="delete" onclick="document.getElementById('deleteform').action = 'delete.php';document.getElementById('deleteform').submit();"/> <!--- here on clicking the button the form is submitted and action is set to delete.php Here we have used javaScript document refers to this whole page and now we can access any tag that has its id with help of getElementById() method and after the we specify the operation we want to perform in this case action and submit. ---> 
                    </td> 
                    <td width="50">id</td> 
                    <td width="55">name</td>
                    <td width="47">lastname</td>
                </tr>
 <?php 
 while ($rows = mysql_fetch_array($result)) 
        { /* here we make use of the while loop which fetch the data from the $result int array form and stores in $row now we can display each field from the table with $row[‘field_name’] as below */ 
     ?> 
                <tr>
                    <td>
                        <input type="checkbox" name="empids[]" value="<?php echo $rows['id']; ?>" /> <!--here with each checkbox we send the id of the record in the empids[] array ---> 
                    </td>
                    <td>
                        <?php echo $rows['id'] ?>
                    </td>
                        <td>
                            <?php echo $rows['lastname'] ?>
                        </td>
                        <td><?php echo $rows['name'] ?></td> 
                            <?php } ?>
                </tr>
            </table>
        </form> ?>
    </body>
</html>
<?php 
require_once('conection.php'); 
?>
 <?php
 if (isset($_GET['delete'])) /* checks weather $_GET['delete'] is set*/
     {
     if (isset($_GET['empids'])) /* checks weather $_GET['empids'] is set */ 
         { 
         $checkbox = $_GET['empids']; /* value is stored in $checbox variable */ 
         if (is_array($checkbox)) 
             { 
             foreach ($checkbox as $key => $your_slected_id) /* for each loop is used to get id and that id is used to delete the record below */ 
                 { 
                 $q="DELETE FROM test_mysql WHERE id=$your_slected_id "; /* Sql query to delete the records whose id is equal to $your_slected_id */
                 mysql_query($q,$conection) ; /* runs the query */ 

                 } 
                 header("location:multiple_delete.php"); /* Goes back to index.php */ 

                 } 

                 } else 
                     { 
                     echo" you have not selected reords .. to delete"; 

                     } 

                     } ?>

在表中显示记录
身份证件
名称
姓氏
?>
delete.php

<?php $hostname_conection = "localhost"; /* this is the server name(assigned to variable) which is localhost since it runs on local machine */ 
$database_conection = "company"; /* this is the database name( assigned to variable)*/ 
$username_conection = "root"; /* user name (assigned to variable)*/
$password_conection = ""; /*password (assigned to variable) */ 
$conection = mysql_connect($hostname_conection, $username_conection, $password_conection) or trigger_error(mysql_error(),E_USER_ERROR); /* Mysql_connect function is used to conncet with database it takes three parameters server/hostname, username,and password*/ 
mysql_select_db($database_conection,$conection) or die(mysql_error("could not connect to database!")); /* Mysql_select is used to select the database it takes two parameters databasename and connection variable in this case $conection */ 
?>
<?php require_once('conection.php'); ?> 
<?php 
in
/* now to display the data from the database which we inserted in above form we */ /* we make the query to select data from the table EMP */ 
            $display = "select * from test_mysql";
        $result = mysql_query($display, $conection) or die(mysql_error()); /* the query is executed and result of the query is stored in variable $result */ 
        if ($result == FALSE) {
            die(mysql_error()); /* displays error */
        } ?> <h1 align="center"> Displaying Recods in Table </h1> 
        <form method="get" action="" id="deleteform" > 
            <table width="245" border="1" align="center"> 
                <tr>
                    <td width="51">
                        <input type="submit" name="delete" id="button" value="delete" onclick="document.getElementById('deleteform').action = 'delete.php';document.getElementById('deleteform').submit();"/> <!--- here on clicking the button the form is submitted and action is set to delete.php Here we have used javaScript document refers to this whole page and now we can access any tag that has its id with help of getElementById() method and after the we specify the operation we want to perform in this case action and submit. ---> 
                    </td> 
                    <td width="50">id</td> 
                    <td width="55">name</td>
                    <td width="47">lastname</td>
                </tr>
 <?php 
 while ($rows = mysql_fetch_array($result)) 
        { /* here we make use of the while loop which fetch the data from the $result int array form and stores in $row now we can display each field from the table with $row[‘field_name’] as below */ 
     ?> 
                <tr>
                    <td>
                        <input type="checkbox" name="empids[]" value="<?php echo $rows['id']; ?>" /> <!--here with each checkbox we send the id of the record in the empids[] array ---> 
                    </td>
                    <td>
                        <?php echo $rows['id'] ?>
                    </td>
                        <td>
                            <?php echo $rows['lastname'] ?>
                        </td>
                        <td><?php echo $rows['name'] ?></td> 
                            <?php } ?>
                </tr>
            </table>
        </form> ?>
    </body>
</html>
<?php 
require_once('conection.php'); 
?>
 <?php
 if (isset($_GET['delete'])) /* checks weather $_GET['delete'] is set*/
     {
     if (isset($_GET['empids'])) /* checks weather $_GET['empids'] is set */ 
         { 
         $checkbox = $_GET['empids']; /* value is stored in $checbox variable */ 
         if (is_array($checkbox)) 
             { 
             foreach ($checkbox as $key => $your_slected_id) /* for each loop is used to get id and that id is used to delete the record below */ 
                 { 
                 $q="DELETE FROM test_mysql WHERE id=$your_slected_id "; /* Sql query to delete the records whose id is equal to $your_slected_id */
                 mysql_query($q,$conection) ; /* runs the query */ 

                 } 
                 header("location:multiple_delete.php"); /* Goes back to index.php */ 

                 } 

                 } else 
                     { 
                     echo" you have not selected reords .. to delete"; 

                     } 

                     } ?>

$sql=“从黑名单中选择*”;
$result=$link->query($sql);
$count=mysqli\u num\u行($result);
如果($result->num_rows>0){
而($row=$result->fetch_assoc())
{
回声“;
回声“;
回显“.ID:”$row[“ID”];
回显“.”拨号目标“.”行[“拨号目标”];
回显“.”目的地:“$row[“pozn”]”;
回显“.”日期:“.$行[“块日期”];
回声“.”;
回声“;
回声“;
回声“
”; } } 其他的 { 回显“0结果”; } 如果(isset($_POST['Delete'])) { 对于($i=0;$iquery($del); } 如果($结果) { 回声“; } }
$sql=“从黑名单中选择*”;
$result=$link->query($sql);
$count=mysqli\u num\u行($result);
如果($result->num_rows>0){
而($row=$result->fetch_assoc())
{
回声“;
回声“;
回显“.ID:”$row[“ID”];
回显“.”拨号目标“.”行[“拨号目标”];
回显“.”目的地:“$row[“pozn”]”;
回显“.”日期:“.$行[“块日期”];
回声“.”;
回声“;
回声“;
回声“
”; } } 其他的 { 回显“0结果”; } 如果(isset($_POST['Delete'])) { 对于($i=0;$iquery($del); } 如果($结果) { 回声“; } }

您的输入超出了您的
标签;第一个主要问题。此外,没有
操作或方法设置到应该执行工作的文件中。例如:
更正此问题将您的输入文件放入表单
请参考此问答,类似于y我们的答案你会在那里找到。这是我开始的答案,在过去对我帮助很大。另外,如果没有设置,form方法默认为GET。Do
-你现在有足够的信息自己解决这个问题。你的输入超出了你的
标签;第一个主要问题。另外,没有
操作或方法设置为t应该做这项工作的文件。例如:
更正此项,将您的输入文件放入表单中
查阅此问答,这样您将在那里找到与您的答案类似的答案。这是我开始使用的文件,在过去帮了我很多忙。此外,表单方法默认值为GET(如果未设置)。请执行
-您现在有了有足够的信息可以自己解决这个问题。还有1+不使用循环:)简单而优雅,我的内部代码猴子很高兴。
mysql\uu
弃用通知可能会产生更多的“红利”点数,以及SQL和XSS注入。-)使用
mysqli\u
with确实是一种更好、更安全的方法。然而,有些人甚至会建议,但即使是PDO也不具备
mysqli\uu
提供的一些功能;奇怪的是。甚至PDO也需要消毒。许多人认为使用PDO可以解决注入问题,这是错误的。很多人在没有提到
mysql\uu
弃用通知的情况下,或者不投赞成票,或者不投反对票,你想知道;-)@Fred ii-感谢您讲述PDO与mysqli扩展的比较。我更新了答案。1+因为没有使用循环:)简单而优雅,我的内部代码猴子很高兴。
mysql\ucode>弃用通知可能会产生更多的“额外”分数,以及SQL和XSS注入。;-)与一起使用
mysqli\uu
确实是一种更好、更安全的方法。然而,有些人甚至会建议,但即使是PDO也不具备
mysqli\uu
提供的一些功能;奇怪的是。甚至PDO也需要消毒。许多人认为使用PDO可以解决注入问题,这是错误的。很多人在没有提到
mysql\uu
弃用通知的情况下,或者不投赞成票,或者不投反对票,你想知道;-)@Fred ii-感谢您讲述PDO与mysqli扩展的比较。我更新了答案。但是我的按钮仍然不起作用。但是我的按钮仍然不起作用