Why cannot I delete the selected data?

Source: Internet
Author: User
What's wrong? {Code...} is not correct?

        
  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']));        }    ?>

You write this code strangely.
First, why can't I delete it:
Your input box does not have the value attribute. Therefore, your $ _ POST ['name'] cannot get the value.
You can change it

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

Then I look at your code. do you want to delete multiple choices? Then you need to submit an array to php by post, then you can modify the name attribute of input:

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

The post received by php is as follows:

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

In this case, you need to process this $ name. Change your SQL statement

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

For example:

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

Then, you 'd better judge the is_post code before the output list. otherwise, output the code first and then delete the code. The result is not displayed.

Is this the first entry?

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.