『壹』 php如何實現時時搜索功能
樓主說的可是自動提示功能, 類似網路搜索時出來的下拉提示
具體實現方案無非就是ajax+頁面顯示特效, 不過現在不用這么麻煩, 用線程的插件支持, 可以查一下autocomplete jquery的資料
『貳』 php 如何實現文章內容搜索
簡單的方法是
SELECT * FROM 文章表 WHERE 內容 like '%新聞%';
下面另外二種方法給你參考
另外業務層方面的方法是設置標簽,然後關聯表裡面記錄對應的文章ID
另外技術層方面的方法是使用搜索引摯,如sphinx等。這是高級部分
『叄』 怎麼在網頁上用PHP做個搜索功能
通過from表單,將查詢的關鍵詞,通過 like 跟數據進行模糊查詢對比x0dx0a從topics表中查詢欄位subject與傳進來的參數'$_POST['topic']進行比較模糊查詢x0dx0a設subject欄位數據為:數學,英語,物理,化學,英文x0dx0a$subject=$_POST['topic']; x0dx0a$sql = "select * from topics where subject like '%" .$subject. "%'";x0dx0a$result = mysql_query($sql);x0dx0a若從表單提交的『topic』值為「學」,得到的結果將是:數學,化學x0dx0a多個欄位匹配查詢:x0dx0a$sql = "select id,subject from topics where (id like '%" .$id. "%') or (name like '%" .$name. "%') or (subject like '%" .$subject. "%') order by id desc";x0dx0a結果依據欄位id的順序
『肆』 PHP中怎麼實現關鍵字搜索
PHP要實現關鍵字查搜索,需要用到like關鍵字來組合查詢條件
like具體實現方法如下:
例一:
1$userForm=M('user');
1$where['name']=array('like','phpernote%');
2$userForm->where($where)->select();
這里的like查詢即為:name like 'phpernote%'
例二:
1$where['name']=array('like',array('%phpernote%','%.com'),'OR');
這里的like查詢即為:name like '%phpernote%' or name like '%.com'
例三:
1$where['name']=array(array('like','%a%'),array('like','%b%'),array('like','%c%'),'phpernote','or');
這里的like查詢即為:(`name` LIKE '%a%') OR (`name` LIKE '%b%') OR (`name` LIKE '%c%') OR (`name` = 'phpernote')
例四:
1$where['_string']='(namelike"%phpernote%")OR(titlelike"%phpernote")'
這里的like查詢即為:name like '%phpernote%' or title like '%phpernote'
『伍』 php中如何實現搜索功能
資料庫內的搜索還是普通的關鍵字匹配搜索啊?
如果是資料庫直接模糊查詢關鍵字,如果是其他一些普通的匹配,直接正則就行了啊