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ù)庫操作入門教程》、《php+mysqli數(shù)據(jù)庫程序設(shè)計(jì)技巧總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家PHP程序設(shè)計(jì)有所幫助。
相關(guān)文章
php返回相對時(shí)間(如:20分鐘前,3天前)的方法
這篇文章主要介紹了php返回相對時(shí)間的方法,可實(shí)現(xiàn)返回如:20分鐘前、3天前等格式時(shí)間,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04
linux php mysql數(shù)據(jù)庫備份實(shí)現(xiàn)代碼
想在PHP后臺(tái)管理直接能夠備份數(shù)據(jù)庫,于是想呀想,一直沒有什么思路,一開始是考慮用php來訪問服務(wù)器安裝mysql的目錄,比如 /usr/local/mysql/data目錄,直接把下面對應(yīng)的文件進(jìn)行備份2009-03-03
PHP怎么實(shí)現(xiàn)網(wǎng)站保存快捷方式方便用戶隨時(shí)瀏覽
網(wǎng)站保存快捷方式以后在瀏覽起來就比較方便了,實(shí)現(xiàn)的方法有很多,下面為大家詳細(xì)介紹下使用PHP實(shí)現(xiàn)網(wǎng)站快捷方式的保存,有此需求的朋友可以參考下,希望對大家有所幫助2013-08-08
使用Xdebug調(diào)試和優(yōu)化PHP程序之[1]
使用Xdebug調(diào)試和優(yōu)化PHP程序之[1]...2007-04-04
PHP中file_put_contents追加和換行的實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄狿HP中file_put_contents追加和換行的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-04-04

