• JAVA日报


    php(ex01b.php)

    <?php
    if(isset($_POST['name'])&&isset($_POST['sex'])&&isset($_POST['hobby'])&&isset($_POST['area'])&&isset($_POST['ect'])&&$_GET['act']=='add'){
    $ID = $_POST['name'];
    $sex = $_POST['sex'];
    $hobby = $_POST['hobby'];
    $area = $_POST['area'];
    $ect = $_POST['ect'];
    echo $_GET['act'].'++++';
    $conn=mysqli_connect("localhost","root","123","text3") or die("数据库连接失败");
    mysqli_query($conn,'set names utf8');

    $sql2="insert into student (id,sex,hobby,area,ect) VALUES ('$ID','$sex','$hobby','$area','$ect')";

    if ($conn->query($sql2) === TRUE) {
    } else {
    echo "Error: " . $sql2. "<br>" . $conn->error;
    }

    $conn->close();
    }
    else if(isset($_POST['name'])&&isset($_POST['sex'])&&isset($_POST['hobby'])&&isset($_POST['area'])&&isset($_POST['ect'])&&$_GET['act']=='update'){
    $ID1 = $_GET['ID'];
    $sex1 = $_GET['sex'];
    $hobby1 = $_GET['hobby'];
    $area1 = $_GET['area'];
    $ect1 = $_GET['ect'];

    $ID = $_POST['name'];
    $sex = $_POST['sex'];
    $hobby = $_POST['hobby'];
    $area = $_POST['area'];
    $ect = $_POST['ect'];
    echo $_GET['act'].'++++';
    $conn=mysqli_connect("localhost","root","123","text3") or die("数据库连接失败");
    mysqli_query($conn,'set names utf8');

    $sql3="update student set id='$ID',sex='$sex',hobby='$hobby',area='$area',ect='$ect' WHERE id='$ID1' and sex='$sex1' and hobby='$hobby1' and area='$area1' and ect='$ect1'";
    echo $sql3;

    if ($conn->query($sql3) === TRUE) {
    echo "成功";
    } else {
    echo "Error: " . $sql3 . "<br>" . $conn->error;
    }

    $conn->close();
    }
    else if(isset($_GET['ID'])&&isset($_GET['sex'])&&isset($_GET['hobby'])&&isset($_GET['area'])&&isset($_GET['ect'])&&$_GET['act']=='delete'){
    $ID = $_GET['ID'];
    $sex = $_GET['sex'];
    $hobby = $_GET['hobby'];
    $area = $_GET['area'];
    $ect = $_GET['ect'];

    echo $_GET['act'].'++++';
    $conn=mysqli_connect("localhost","root","123","text3") or die("数据库连接失败");
    mysqli_query($conn,'set names utf8');

    $sql4="delete from student WHERE id='$ID' and sex='$sex' and hobby='$hobby' and area='$area' and ect='$ect'";
    echo $sql4;

    if ($conn->query($sql4) === TRUE) {
    echo "成功";
    } else {
    echo "Error: " . $sql4 . "<br>" . $conn->error;
    }

    $conn->close();
    }

    ?>
    <div style="position: absolute;height: 60%; 70%;left: 20%;top: 15%">
    <table border="1" style="100%;">
    <tr style="100%;">
    <td colspan="7" style="text-align: center">学生个人信息表</td>
    </tr>
    <tr style="height: 18px;">
    <td style=" 15%">姓名</td>
    <td style=" 15%">性别</td>
    <td style=" 20%">爱好</td>
    <td style=" 25%">家庭住址</td>
    <td style=" 20%">备注</td>
    <td style=" 5%"></td>
    </tr>
    <?php
    $conn2=mysqli_connect("localhost","root","123","text3") or die("数据库连接失败");
    mysqli_query($conn2,'set names utf8');
    $sql3="select * from student";
    $result=mysqli_query($conn2,$sql3)or die("数据查询失败");
    foreach ($result as $value){
    echo '<tr style="height: 18px"><td>'.$value["id"].'</td><td>'.$value["sex"].'</td><td>'.$value["hobby"].'</td><td>'.$value["area"].'</td><td>'.$value["ect"].'</td><td><a href="ex01c.php?ID='.$value["id"].'&sex='.$value["sex"].'&hobby='.$value["hobby"].'&area='.$value["area"].'&ect='.$value["ect"].'">修改</a>&nbsp;&nbsp;<a href="ex01b.php?act=delete&ID='.$value["id"].'&sex='.$value["sex"].'&hobby='.$value["hobby"].'&area='.$value["area"].'&ect='.$value["ect"].'">删除</a></td></tr>';
    }
    $conn2->close();
    ?>
    </table>
    </div>
  • 相关阅读:
    Apriori 算法-如何进行关联规则挖掘
    Nginx 常用命令
    Nginx Location匹配规则
    Nginx 负载均衡
    angular 路由传参的三种方式
    JAVA中final关键字的作用
    Python函数参数和注解是什么
    JMeter测试计划配置项解析
    JMeter元件作用域实践指南
    原来Python函数只是个对象
  • 原文地址:https://www.cnblogs.com/mumulailai/p/14912377.html
Copyright © 2020-2023  润新知