1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>查询</title> <style> h1,form{ text-align: center; } table{ margin: auto; border: 2px solid blue; } table{ margin:auto; border:2px solid blue; } tr:nth-child(odd){ background: #ccc; } tr:nth-child(even){ background: yellow; } .form01{ margin:auto; height: 74px; } </style> <script> function check1(){ var db = document.getElementById("bd"); db.action = "./insert.php"; db.submit(); } function check2(){ var db = document.getElementById("bd"); db.action = "./update.php"; db.submit(); } function check3(){ var db = document.getElementById("bd"); db.action = "./delete.php"; db.submit(); } </script> </head> <body> <h1>所有老师信息</h1> <div class="form01"> <form action='./index.php' method='post'> <input type='text' name='query'/> <input type='submit' name='btnQuery' value='搜索'/> </form> <br/> <form> <form action='' method='post' id='bd'> <input type='submit' name='insert' value='新增' onclick='check1()'> <input type='submit' name='' value='编辑' onclick='check2()'> <input type='submit' name='delete' value='删除' onclick='check3()'> </div> <table border="1" width='600px' style='text-align:center;'> <tr> <td></td> <td>工号</td> <td>姓名</td> <td>性别</td> <td>出生日期</td> <td>所在部门</td> </tr> <?php $query = $_POST['query']; //$_SESSION['query']="$query"; $db = new mysqli("localhost", "root","123456","studentmis"); if(!$db) { echo "数据库连接失败!!!"; } if(isset($_POST['btnQuery']) && $query != null) { //session_start(); $sql="SELECT laoshi.e_id,laoshi.e_name, laoshi.sex, laoshi.date_birth, bumen.dept_name from laoshi left join bumen on bumen.dept_no = laoshi.dept_no WHERE laoshi.e_id = '$query' or laoshi.e_name = '$query' or bumen.dept_name = '$query'"; }else{ $sql="SELECT e_id,e_name, sex, date_birth, bumen.dept_name from laoshi left join bumen on bumen.dept_no = laoshi.dept_no"; } $db->query("SET NAMES utf8"); $res=$db->query($sql); ?> <?php if($res){ while($row=$res->fetch_assoc()) { $gonghao=$row['e_id']; $xingming=$row['e_name']; $sex=$row['sex']; $shengri=$row['date_birth']; $suozaibumen=$row['dept_name']; echo "<center><tr><td><input type='checkbox' name='sel[]' value='".$row["e_id"]."'/></td></center>". "<td>$gonghao</td> <td>$xingming</td> <td>$sex</td> <td>$shengri</td> <td>$suozaibumen</td> </tr>"; } //释放结果集 $res->close; } //关闭连接 $db->close(); ?> </table> </form> </body> </html>
|