PHP+MySQL實(shí)現(xiàn)模糊查詢員工信息功能示例
本文實(shí)例講述了PHP+MySQL實(shí)現(xiàn)模糊查詢員工信息功能。分享給大家供大家參考,具體如下:
一、代碼
注意兩點(diǎn):
1、用Notepad+編輯時(shí),格式選擇:【編碼字符集】->【中文】->【gb2312】
2、
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
conn.php
<?php $connID=mysql_connect("localhost","root","root"); mysql_select_db("db_database13", $connID); mysql_query("set names gbk"); ?>
index.php
<?php session_start(); include("conn/conn.php");?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title> 查詢企業(yè)員工的詳細(xì)信息</title> <style type="text/css"> <!-- .STYLE4 {font-size: 13px} .STYLE5 {font-family: "華文琥珀"; font-size: 20px;} .STYLE6 {color: #990000} --> </style> </head> <body> <table width="450" height="28" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center" class="STYLE5 STYLE6">查詢企業(yè)員工的詳細(xì)信息</td> </tr> </table> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <table width="450" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#990000"> <tr> <td width="176" align="center" bgcolor="#FFFFFF"><span class="STYLE1 STYLE4">按照員工的編號(hào)查詢</span></td> <td width="182" bgcolor="#FFFFFF"><input name="number" type="text" id="number" /></td> <td width="84" height="25" bgcolor="#FFFFFF"><input type="hidden" name="flag" value="1" /><input name="submit" type="submit" value="提交" /></td> </tr> </table> </form> <table width="450" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#990000"> <tr> <td width="67" align="center" bgcolor="#FFFFFF" class="STYLE4">編號(hào)</td> <td width="72" align="center" bgcolor="#FFFFFF" class="STYLE4">姓名</td> <td width="119" align="center" bgcolor="#FFFFFF" class="STYLE4">電話</td> <td width="182" height="25" align="center" bgcolor="#FFFFFF" class="STYLE4">地址</td> </tr> <?php if(isset($_POST["flag"])) { $query=mysql_query("select * from tb_employee where number like '%".$_POST["number"]."%'"); if($query) { while($myrow=mysql_fetch_array($query)) { ?> <tr> <td align="center" bgcolor="#FFFFFF" class="STYLE4"><span class="STYLE2"><?php echo $myrow[number];?></span></td> <td align="center" bgcolor="#FFFFFF" class="STYLE4"><span class="STYLE2"><?php echo $myrow[name];?></span></td> <td height="23" align="center" bgcolor="#FFFFFF" class="STYLE4"><span class="STYLE2"><?php echo $myrow[tel];?></span></td> <td height="23" align="center" bgcolor="#FFFFFF" class="STYLE4"><span class="STYLE2"><?php echo $myrow[address];?></span></td> </tr> <?php } } } ?> </table> </body> </html>
二、運(yùn)行結(jié)果
瀏覽器選擇的編碼是gbk
更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php+mysql數(shù)據(jù)庫(kù)操作入門教程》、《php+mysqli數(shù)據(jù)庫(kù)程序設(shè)計(jì)技巧總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》及《php常見數(shù)據(jù)庫(kù)操作技巧匯總》
希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。
相關(guān)文章
php代碼中使用換行及(\n或\r\n和br)的應(yīng)用
瀏覽器識(shí)別不了\n或\r\n,這兩個(gè)換行符是文本換行符,文本文件有效;如果需要將結(jié)果輸出到瀏覽器或打印到顯示器,代碼中使用br;如果只是在源代碼中換行,則使用\n或\r\n,感興趣的朋友可以了解下,或許對(duì)你學(xué)習(xí)php有所幫助2013-02-02解析用PHP實(shí)現(xiàn)var_export的詳細(xì)介紹
本篇文章是對(duì)使用PHP實(shí)現(xiàn)var_export的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06php實(shí)現(xiàn)數(shù)組按指定KEY排序的方法
這篇文章主要介紹了php實(shí)現(xiàn)數(shù)組按指定KEY排序的方法,涉及php操作數(shù)組排序的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03php將文件夾打包成zip文件的簡(jiǎn)單實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄猵hp將文件夾打包成zip文件的簡(jiǎn)單實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-10-10