模糊查詢實例-搜索頁

期望是什么?


怎么做?

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>搜索頁</title>

<!--mui.min.css需要你自己下載-->

<link rel="stylesheet" href="css/mui.min.css"? />

<!--reset.css見附注1提供-->

<link rel="stylesheet" href="css/reset.css"? />

<!--reset.css見附注2提供-->

<link rel="stylesheet" href="css/fontIcons/iconfont.css"? />

<!--searchPage.css見附注3提供-->

<link href="css/WxPages/searchPage.css" rel="stylesheet" />

<script src="js/mui.min.js"></script><!--自行下載-->

<script src="js/jquery.js"></script><!--自行下載-->


</head>

<body>

<header class="mui-bar mui-bar-nav head">

? ? <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>

? ? <h1 class="mui-title">標題</h1>

</header>

<div class="mui-content">

? ? <div class="search_m_page mui-content">

<div class="product_search_page">

<form action="" method="GET">

<div class="top_search mui-input-row pos_rel">

<div class="search_wrap pos_rel">

<input type="text" class="product_search" name="keywords" value="" placeholder="請輸入商品名稱"/>

<span class="search_icon pos_abs">

<span class="iconfont icon-fangdajing"></span>

</span>

</div>

? ? <div class="search_btn_wrap pos_abs">

? ? <input type="submit" value="搜索"/>

? ? </div>

</div>

</form >

<div class="search_history_wrap">

<div class="history_title posi_rel">

<span class="title_text">歷史搜索</span>

<span class="delete_icon posi_abs">

<span class="iconfont icon-shanchu"></span>

</span>

</div>

<ul class="history_list">

<?php

//判斷并獲取表單數(shù)據(jù)

? $keywords=isset($_GET['keywords']) ? trim($_GET['keywords']):'';



? ? ? ? ? ? ? ? ? ? ? $conn=@mysql_connect('localhost','root','root');

//設(shè)置數(shù)據(jù)庫編碼

? ? ? ? ? ? ? ? ? ? ? mysql_query("set names utf8");


//連接數(shù)據(jù)庫

mysql_query("use php39");

? ? ? ? ? ? ? ? ? ? ? $sql="select *from user WHERE username LIKE '%{$keywords}%'";

? ? ? ? ? ? ? ? ? ? ? $result=mysql_query($sql);

? ? ? ? ? ? ? ? ? ? ? $user=array();

? ? ? ? ? ? ? ? ? ? ? if(!empty($keywords)){

? ? ? ? ? ? ? ? ? ? ? while($row=mysql_fetch_array($result)){

? ? ? ? ? ? ? ? ? ? ? $row['username'] = str_replace($keywords,'<font color="red">'.$keywords.'</font>', $row['username']);

? ? ? ? ? ? ? ? ? ? ? $user[]=$row;



? ? ? ? ? ? ? ? ? ? ? }





? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ?>

? ? ? ? ? ? ? ? ? <?php


? ? ? ? ? ? ? ? ? if($user){


? ? ? ? ? ? ? ? ? ? ? foreach($user as $key=>$value){


? ? ? ? ? ? ? ? ? ? ? echo"<li><a>".$value['username']."</a></li>";



? ? ? ? ? ? ? ? ? ? ? }


? ? ? ? ? ? ? ? ? ? ? }else{


? ? ? ? ? ? ? ? ? ? ? echo "沒有數(shù)據(jù)";


? ? ? ? ? ? ? ? ? ? ? }



? ? ? ? ? ? ? ? ? ?>

</ul>

</div>

</div>

</div>

</div>

</body>

</html>

附注1:reset.css

@charset "utf-8";

/** reset **/

/*隱藏廣告*/

#EG0phD8f{

display: none !important;

}

html,body {

position: relative;

width: 100%;

height: 100%;

margin: 0;

padding: 0;

font: 14px/1.5 Tahoma, Helvetica, Arial, "黑體", sans-serif;

background: #eee;

}

form,label,input,h1,h2,h3,h4,ul,li,dl,dt,dd,p {

margin: 0;

padding: 0;

}

ul {

list-style: none;

}

input {

outline: none;

}

a {

color: #333333;

text-decoration: none;

}

.fl {

float: left;

}

.fr {

float: right;

}

.posi_abs {

position: absolute;

}

.posi_rel {

position: relative;

}

.clearfix:before,

.clearfix:after {

content: '';

display: table;

}

.clearfix:after {

clear: both;

}

.clearfix {

*zoom: 1;

}

.red {

color: #fe355c;

}

.gray {

color: #666666;

}

.blue_word {

color: #008fd7;

}

.posi_rel {

position: relative;

}

.posi_abs {

position: absolute;

}

em {

font-style: normal;

}

.none {

display: none;

}

/*白色背景*/

.back_color {

background: #fff;

}

.back_gray {

background: #dbdbdb;

color: #fff;

}

.logo {

width: 133.5px;

height: 45px;

margin-top: 40px;

}

.red_btn {

background: #e62129;

color: #fff;

}

.mui-input-group .mui-input-row:after {

right: 15px;

background-color: #ebebeb;

}

.mui-input-group:after,

.mui-input-group:before {

height: 0;

}

::-webkit-input-placeholder {

color: #ccc;

font-size: 13px;

}

:-moz-placeholder {

color: #ccc;

font-size: 13px;

}

:-ms-input-placeholder {

color: #ccc;

font-size: 13px;

}

.mui-input-row label {

padding: 14px 15px;

}

@font-face {font-family: 'iconfont';

? ? src: url('fontIcons/iconfont.eot'); /* IE9*/

? ? src: url('fontIcons/iconfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */

? ? url('fontIcons/iconfont.woff') format('woff'), /* chrome、firefox */

? ? url('fontIcons/iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/

? ? url('fontIcons/iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */

}

.iconfont {

font-family: "iconfont";

font-size: 24px;

font-style: normal;

-webkit-font-smoothing: antialiased;/*字體清除鋸齒效果*/

}

/*快捷導(dǎo)航*/

.quick_form{

height: 100%;

}

.tab_quick_box{

position: fixed;

right: 0;

bottom: 5%;

z-index: 99;

text-align: center;

color: #fff;

}

/*回到頂部*/

.tab_quick_box .go_top{

display: inline-block;

width: 50px;

height: 35px;

line-height: 35px;

text-align: center;

background: rgba(0,0,0,0.72);

position: relative;

top: -24px;

-moz-border-radius:4px 0 0 4px;

-webkit-border-radius: 4px 0 0 4px;

border-radius: 4px 0 0 4px;

font-size: 20px;

}

.com_quick_btn{

display: block;

width: 50px;

font-size: 10px;

line-height: 10px;

text-align: center;

padding-bottom: 5px;

-ms-transform: translate(0,-50%);

-moz-transform: translate(0,-50%);

-webkit-transform: translate(0,-50%);

transform: translate(0,-50%);

background: rgba(0,0,0,0.72);

-moz-border-radius:4px 0 0 4px;

-webkit-border-radius: 4px 0 0 4px;

border-radius: 4px 0 0 4px;

color: #fff;

}

.com_quick_btn i,.com_quick_btn1 i{

display: block;

width: 50px;

height:25px;

line-height: 25px;

text-align: center;

font-size: 20px;

}

.fast_slider_nav .mui-popover.mui-popover-action{

top: 0;

}

.com_quick_btn1{

display: block;

width: 50px;

font-size: 10px;

line-height: 10px;

text-align: center;

padding-bottom: 5px;

background: rgba(0,0,0,0.5);

-moz-border-radius:4px 0 0 4px;

-webkit-border-radius: 4px 0 0 4px;

border-radius: 4px 0 0 4px;

color: #fff;

}

/*彈出遮罩層中的內(nèi)容樣式*/

.inner_tab{

position: absolute;

width: 50px;

right: 0;

top: 57%;

-ms-transform: translate(0,-50%);

-moz-transform: translate(0,-50%);

-webkit-transform: translate(0,-50%);

transform: translate(0,-50%);

}

.inner_tab ul{

background: #fff;

-moz-border-radius:4px 0 0 4px;

-webkit-border-radius: 4px 0 0 4px;

border-radius: 4px 0 0 4px;

text-align: center;

padding-bottom: 10px;

}

.inner_tab ul li a i{

display: block;

height: 30px;

line-height: 40px;

font-size: 20px;

text-align: center;

-webkit-font-smoothing: antialiased;/*字體清除鋸齒效果*/

? ? -webkit-text-stroke-width: 0.2px;/*文本外邊框大小*/

? ? -moz-osx-font-smoothing: grayscale;

}

.inner_tab ul li a span{

font-size: 10px;

}

/*底部固定tab*/

.fixed-foot-tab.mui-bar-tab{

box-shadow: 0 0 1px rgba(0,0,0,.3);

-webkit-box-shadow: 0 0 1px rgba(0,0,0,.3);

background-color: #fff;

}

.fixed-foot-tab.mui-bar-tab .iconfont{

display: block;

font-size: 20px;

line-height: 1.2;

position: relative;

top: 4px;

}

.fixed-foot-tab.mui-bar-tab .mui-tab-item.mui-active {

color: #ff2150;

}

.fixed-foot-tab.mui-bar-tab .mui-tab-label {

font-size: 10px;

}

.head {

background: #000;

display: none;

}

.head a,

.head .mui-title {

color: #fff;

}

/*mui樣式修改*/

.mui-bar-nav~.mui-content,.mui-content{

padding-top: 0;

}

附注2:

需要自己下載字體圖標文件

附注3:searchPage.css

@charset "utf-8";

.hide{

display: none;

}

/*定位元素*/

.pos_rel{

position: relative;

}

.pos_abs{

position: absolute;

}

.search_m_page{

height: 100%;

background-color: #fff;

}

/*搜索列表*/

.top_search{

padding: 6px 0;

}

.top_search .search_wrap{

padding: 0 65px 0 10px;

}

.top_search .search_wrap .product_search{

height: 32px;

padding-left: 30px;

margin: 0;

font-size: 12px;

line-height: 1;

text-align: left;

background-color: #f0f0f0;

border-radius: 15px;

border-color: transparent;

}

.top_search .search_wrap .search_icon{

left: 20px;

top: 50%;

margin-top: -8px;

font-size: 16px;

line-height: 1;

color: #999999;

}

.top_search .search_btn_wrap{

right: 5px;

top: 5px;

width: 55px;

font-size: 20px;

line-height: 1;

text-align: center;

}

.top_search .search_btn_wrap button{

width: 100%;

padding: 8px 0;

font-size: 12px;

background-color: #fe355c;

}

/*搜索歷史*/

.search_history_wrap{

padding: 0 10px;

font-size: 12px;

line-height: 26px;

}

.search_history_wrap .history_title{

padding: 5px 0;

font-size: 14px;

}

/*刪除圖標*/

.search_history_wrap .history_title .delete_icon{

right: 0;

top: 5px;

}

.search_history_wrap .history_title .delete_icon .iconfont{

font-size: 14px;

}

/*搜索歷史列表*/

.search_history_wrap .history_list{

font-size: 0;

}

.search_history_wrap .history_list li{

display: inline-block;

vertical-align: middle;

padding: 4px 5px 4px 0;

font-size: 12px;

}

.search_history_wrap .history_list li a{

display: block;

padding: 0 12px;

background-color: #f5f5f5;

border-radius: 13px;

}

/*無歷史記錄*/

.no_history{

padding: 45px 0;

font-size: 14px;

text-align: center;

color: #666666;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 229,362評論 6 537
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,013評論 3 423
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 177,346評論 0 382
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,421評論 1 316
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,146評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,534評論 1 325
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,585評論 3 444
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,767評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,318評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 41,074評論 3 356
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,258評論 1 371
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,828評論 5 362
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 44,486評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,916評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,156評論 1 290
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,993評論 3 395
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,234評論 2 375

推薦閱讀更多精彩內(nèi)容

  • 不會用代碼框,所以看著有些亂套,,,,html部分 <!DOCTYPE html> 迅雷看看 ...
    這就是個帥氣的名字閱讀 1,552評論 0 0
  • 文/居里社 公牛: 目前的競爭白日化pk進行時,揪著一個懸著的心等待著一場惡戰(zhàn)。公牛牌面的走勢,圣杯主導(dǎo),情感流露...
    居里葉閱讀 403評論 0 4
  • 我是一個鬼,拿一枚樹杈,在半空飄著捉鬼。鬼真多呀,來來往往,成行成堆的,都一樣帥氣,一樣年輕,青一色白邊藍色...
    影視成長筆記小刨手閱讀 394評論 0 1