zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    运行ConnectionDemo时遇到的问题及解决方案
    xampp启动MySQL出现Error: MySQL shutdown unexpectedly.
    20175227张雪莹 2018-2019-2 《Java程序设计》第八周学习总结
    KMS
    MAC 添加共享,脚本执行
    zabbix企业应用之windows系统安装omsa硬件监控
    SCCM大致安装过程,参考前辈教程完成部署
    MAC加域重复跳出---"talagent"想使用“本地项目” 的钥匙串
    CentOS Linux解决 Device eth0 does not seem to be present
    zabbix3.0.4 部署History
  • 原文地址:https://www.cnblogs.com/mumulailai/p/14912377.html
Copyright © 2011-2022 走看看