您的位置:

文本搜索php,文本搜索app

本文目录一览:

关于PHP文本数据库搜索请问怎么做 - 技术问答

先读取文本文件啊,在文本文件中搜索,如果文本较小的话可以直接用函数查找

PHP文本数据库的搜索方法

PHP文本数据库的搜索方法

searchstr=("/".preg_quote($searchstr)."/");

//$searchstr是查找的关键字

$records=file($file);//获取所有的记录数

//$file是查找的数据文件

$search_reocrds=preg_grep

($searchstr,

$records);//开始查找记录

//$search_reocrds为查找到的记录数

unset($records);

if($search_records){

//开始显示记录,写下你自己的处理程序********************

while

(list

($key,

$val)

=

each

(

$search_records))

{

echo

"$val

";

}

//****************************************************

}

php中,关于文本框搜索功能

PHP code

?php

if($_SERVER['REQUEST_METHOD'] == "POST") {$a[]="Anna1";

$a[]="Anna2";

$a[]="Anna3";

$a[]="Anna4";

$a[]="Anna5";

$a[]="Anna6";

$a[]="Brittany1";

$a[]="Brittany2";

$a[]="Brittany3";

$a[]="Brittany4";

$a[]="Brittany5";

$a[]="Brittany6";

$a[]="Brittany7";

$a[]="Cinderella1";

$a[]="Cinderella2";

$a[]="Cinderella3";

$a[]="Cinderella4";

$a[]="Cinderella5";

$a[]="Cinderella6";

$a[]="Cinderella7";

$a[]="Diana1";

$a[]="Diana2";

$a[]="Diana3";

$a[]="Diana4";

$a[]="Diana5";

$a[]="Diana6";

$a[]="Diana7";

$a[]="Eva";

$a[]="Fiona";

$a[]="Gunda";

$a[]="Hege";

$a[]="Inga";

$a[]="Johanna";

$a[]="Kitty";

$a[]="Linda";

$a[]="Nina";

$a[]="Ophelia";

$a[]="Petunia";

$a[]="Amanda";

$a[]="Raquel";

$a[]="Cindy";

$a[]="Doris";

$a[]="Eve";

$a[]="Evita";

$a[]="Sunniva";

$a[]="Tove";

$a[]="Unni";

$a[]="Violet";

$a[]="Liza";

$a[]="Elizabeth";

$a[]="Ellen";

$a[]="Wenche";

$a[]="Vicky";

//get the q parameter from URL

$q = $_POST["q"];

$r = preg_grep("/^$q/i", $a);

exit(join('br', $r));

}

?

script type="text/javascript" src=""/script

script

function showHint(s) {

if($.trim(s) == '') return;

$('#txtHint').css('display', '');

$('#txtHint').load('', {q : s});

}

/script

div

form action="gethint.php" method="get" name="q"

input type="text" id="q" name="q" onkeyup="showHint(this.value)" style="width:300px; height:32px;" /

input type="submit" style="width:80px; height:34px;" value="Search"/

p id="txtHint" style="width:600px;diplay:none"/p

/form

/div