How to delete multiple rows from mysql database with checkbox using PHP?

后端 未结 4 861
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 22:25

I try to delete my data in \"admin\" database, but the delete button does not function.

This is my top part



        
4条回答
  •  春和景丽
    2021-01-16 23:17

    include all the input elements within your

    tags: all inputs are here

    update:

    
    

    to (id doesn't matter here):

    
    

    and your button code:

    
    

    to

    
    

    set opening

    tag to

    Note: I assume below codes are in delete.php file. if not replace "delete.php" with that name in above opening form tag.

    your delete.php file:

    
    

    Note: Since mysql_ will deprecate on future, better is use mysqli extension. But before use that, you have to enable it on your server. mysqli is a part of php and newer version of php has it but not enabled. To enable this, view php info page and find the path of php.ini file in "Loaded Configuration File" row on that page. You can see php info page by loading below php file in the browser:

    
    

    open that php.ini file in a text editor and un-comment or add a line extension=php_mysqli.dll at the extensions list there. also search for "extension_dir" and open the directory it says and make sure php_mysqli.dll file is there. (you may have .so extension if you not use windows OS)

    Then restart your server and you are done!

    By Fred -ii-

    Using mysqli_ with prepared statements is indeed a better and safer method. However, some will even suggest PDO, but even PDO doesn't have some of the functionalities that mysqli_ offers; strangely that. Even PDO needs sanitization. Many think that using PDO will solve injection issues, which is false. -Thanks Fred.

提交回复
热议问题