Jump to content

Notice: Undefined variable: delete in C:\xampp\htdocs\dbmultidelete.php on line 60


Thunder_Wolf

Recommended Posts

I have 2 issues happening, first one I need to get resolved is, line 60 is giving me a 'Notice: Undefined variable: delete'. This codes had multi issues but was able to resolve all but this one and my table not filling in with the data from my database. If you need any other info please let me know, Again I am new at this.

 

                        <tr>
                        <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit"

                        id="delete value="delete"></td>
                       </tr>

 

                       <?php

                        // Check if delete button active, start this
*line 60* -----> if ($delete){
                       for($i=0;$i<$count;$i++){
                       $del_id = $checkbox[$i];
                       $sql = "DELETE FROM $tbl_name WHERE id='$del_id'";
                       $result = mysqli_query($sql);
                       }

                        // if successful redirect to delete_multiple.php
                       if($result){
                       echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">";
                        }
                        }
                        mysqli_close($con);
                        ?>

The error means the $delete hasn't been set yet. You could use isset() to test the variable:

http://php.net/manual/en/function.isset.php

 

Also, since it looks like that variable is supposed to come from an HTML form, you may want to check out the PHP manual for $_POST and $_GET.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.