06-php僱員管理系統-實現顯示僱員資訊列表分頁改進(可以處理大資料100000條)

來源:互聯網
上載者:User

empList.php

<html><head><meta content="text/html;charset=utf-8" http-equiv="content-type"><title>僱員資訊列表</title></head><?php$conn = mysql_connect ( "localhost", "root", "root" ) or die ( mysql_error () );mysql_query ( "set names utf8" );//選擇資料庫mysql_select_db ( "test", $conn );$pageSize = 20; //每頁數$rowCount = 0; //記錄數$pageNow = 1; //當前頁$pageCount = 0; //頁數//根據使用者的點擊收取pagenow的值if (! empty ( $_GET ['pageNow'] )) {$pageNow = $_GET ['pageNow'];}//尋找資料庫中總的記錄有多少條$sql = "select count(id) from emp";$res1 = mysql_query ( $sql );//取出記錄數if ($row = mysql_fetch_row ( $res1 )) {$rowCount = $row [0];}//計算共有多少頁$pageCount = ceil ( $rowCount / $pageSize );//分頁尋找資料庫中的記錄$sql = "select * from emp limit " . ($pageNow - 1) * $pageSize . ",$pageSize";$res2 = mysql_query ( $sql, $conn );//表格顯示分頁查詢後的結果echo "<table width='700px' border='1px' bordercolor='green' cellspacing='0px'>";echo "<tr><th>id</th><th>name</th><th>grade</th>";echo "<th>email</th><th>salary</th><th>刪除</th><th>修改</th></tr>";//這裡我們需要迴圈顯示使用者的資訊while ( $row = mysql_fetch_assoc ( $res2 ) ) {echo "<tr><td>{$row['id']}</td><td>{$row['name']}</td><td>{$row['grade']}</td>";echo "<td>{$row['email']}</td><td>{$row['salary']}</td>";echo "<td><a href='#'>刪除使用者</a></td>";echo "<td><a href='#'>修改使用者</a></td><tr>";}echo "<h1>僱員資訊列表</h1>";echo "<hr/>";echo "</table>";//列印頁碼的超連結//for($i = 1; $i <= $pageCount; $i ++) {//echo "<a href='empList.php?pageNow=$i'>$i</a> ";//}//顯示上一頁和下一頁if ($pageNow > 1) {$prePage = $pageNow - 1;echo "<a href='empList.php?pageNow=$prePage'>上一頁</a> ";}if ($pageNow < $pageCount) {$nextPage = $pageNow + 1;echo "<a href='empList.php?pageNow=$nextPage'>下一頁</a> ";}//顯示當前頁和共有多少頁echo "當前頁{$pageNow}/共{$pageCount}頁";//指定跳轉到某頁echo "<br/><br/>";?> <form action="empList.php" method="get" onsubmit="checkNum();">跳轉到:<inputtype="text" name="pageNow"  style="width:40px;"/>頁 <input type="submit" value="Go" /></form><?php//關閉資源mysql_free_result ( $res2 );mysql_close ( $conn );?></html>

empManage.php

<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"></head><?phpecho "歡迎你," . $_GET ['name'] . "登入成功!...";echo "<br/><a href='login.php'>返回重新登入</a>";?><h1>主介面</h1><a href="empList.php">系統管理使用者</a><br /><a href="#">添加使用者</a><br /><a href="#">查詢使用者</a><br /><a href="#">退出系統</a><br /></html>

login.php

<html><head><meta content="text/html;charset=utf-8" http-equiv="content-type"></head><h1>管理員登入系統</h1><form action="loginProcess.php" method="post"><table><tr><td>使用者id</td><td><input type="text" name="id" /></td></tr><tr><td>密  碼</td><td><input type="password" name="password" /></td></tr><tr><td><input type="submit" value="使用者登入" /></td><td><input type="reset" value="重新填寫" /></td></tr></table></form><?phpif (! empty ( $_GET ['errno'] )) {$errno = $_GET ['errno'];if ($errno == 1) {echo "<font color='red' size='3'>你的使用者名稱或密碼錯誤</font>";}}?></html>

loginProcess.php

<?php//接受使用者的資料//1.id$id = $_POST ['id'];//2.密碼$password = $_POST ['password'];//得到串連$conn = mysql_connect ( "localhost", "root", "root" );if (! $conn) {die ( "串連失敗" . mysql_errno () );}//設定訪問資料庫的編碼mysql_query ( "set names utf8", $conn ) or die ( mysql_errno () );//選擇資料庫mysql_select_db ( "test", $conn ) or die ( mysql_errno () );//發送sql語句驗證$sql = "select password,name from admin where id=$id";//通過id擷取password$res = mysql_query ( $sql, $conn );if ($row = mysql_fetch_assoc ( $res )) {//取出資料庫的密碼if ($row ['password'] == md5 ( $password )) {//合法//取出使用者名稱字$name=$row['name'];header ( "Location:empManage.php?name=$name" );exit ();}}header ( "Location:login.php?errno=1" );exit ();//關閉資源mysql_free_result($res);mysql_close($conn);?>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.