Head First PHP 第4章 removeemail.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Make Me Elvis - Add Email</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
    <img src="blankface.jpg" width="161" height="350" alt="" style="float:right" />
    <img name="elvislogo" src="elvislogo.gif" width="229" height="32" border="0" alt="Make Me Elvis" />
    <p>Please select the email addresses to delete from the email list and click Remove.</p>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <?php
    $dbc = mysqli_connect('localhost:3306', 'root', '', 'elvis_store')
    or die('Error connecting mysql');

    if(isset($_POST['submit']) && !empty($_POST['todelete'])) {
        foreach($_POST['todelete'] as $delete_id) {
            $query = "DELETE FROM email_list WHERE id = $delete_id";
            mysqli_query($dbc, $query)
                or die('Error querying database');
        }

        echo 'Customer(s) removed.<br />';
    }

    $query = "SELECT * FROM email_list";
    $result = mysqli_query($dbc, $query);
    while($row = mysqli_fetch_array($result)) {
        echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]" />';
        echo $row['first_name'];
        echo ' ' . $row['last_name'];
        echo ' ' . $row['email'];
        echo '<br />';
    }
    mysqli_close($dbc);
    ?>
    <input type="submit" name="submit" value="Remove" />
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值