Why can't I delete the selected data?

Source: Internet
Author: User
What's wrong?

        
  
   prepare("delete from class where name=?");        $stmt2->execute(array($_POST['name']));        }    ?>

Reply content:

What's wrong?

        
  
   prepare("delete from class where name=?");        $stmt2->execute(array($_POST['name']));        }    ?>

Your code is rather strange to write.
First say why can't delete:
The box for your input does not have the Value property. So your $_post[' name ' doesn't get a value.
You can change it into

echo ''.$v['name'].'';

Then I look at your code, do you want to do a long choice to delete it? Then you need post to submit an array to PHP, then you can modify the Name property of input:

echo ''.$v['name'].'';

Then the post that was received with PHP is this:

$name = $_POST['name'];//array(name1,name2....)

At this point you need to deal with this $name. Change your SQL statement to

delete from class where name in (name1,name2,name3...)

such as the following:

$sql = "delete from class where name in (" . trim(str_repeat('?,',count($name)),',') . ")";$stmt2 = $pdo->prepare($sql);$stmt2->execute($name);

Then, your judgment Is_post code is best in the output list before, otherwise, first give you output, after deletion, see no effect.

Is this just getting started?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.