当前位置: 首页 > 图文教程 > 网络编程 > PHP > 基于文本的搜索

PHP
PHP新手总结的PHP基础知识
php实现gb2312和unicode间编码转换
用php语言实现数据库连接详细代码介绍
详细解析 PHP 向 MySQL 发送数据过程
利用PHP V5开发多任务应用程序
详细讲解PHP中缓存技术的应用
php escapeshellcmd多字节编码漏洞
《PHP设计模式介绍》导言
《PHP设计模式介绍》第一章 编程惯用法
《PHP设计模式介绍》第二章 值对象模式
《PHP设计模式介绍》第三章 工厂模式
《PHP设计模式介绍》第四章 单件模式
《PHP设计模式介绍》第五章 注册模式
《PHP设计模式介绍》第六章 伪对象模式
《PHP设计模式介绍》第七章 策略模式
《PHP设计模式介绍》第八章 迭代器模式
《PHP设计模式介绍》第九章 观测模式
《PHP设计模式介绍》第十章 规范模式
《PHP设计模式介绍》第十一章 代理模式
《PHP设计模式介绍》第十二章 装饰器模式

PHP 中的 基于文本的搜索


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 234 ::
收藏到网摘: n/a

为了增强我的网站上的功能,本人根据本人的网站的实际,开发了一个基于文本的搜索,现在使用在本人的网站上。为了
和广大网友相互学习交流,本人现在其源码公布,其源码如下:
<?php
$dispstr=array();
$dispstr[1]="disp_os.php?article_id=";
$dispstr[2]="disp_webma.php?article_id=";
$dispstr[3]="disp_webcrea.php?article_id=";
$dispstr[4]="disp_program.php?article_id=";
$dispstr[5]="disp_create.php?article_id=";
$file=file("news.txt");
$file1=file("part.txt");
$file2=file("number.txt");
if(!isset($pagenum)){
$pagenum=1;
}
$lesssign=0;
$num=count($file);
$dispnumbeg=6*($pagenum-1);;
$artnumeof=6*$pagenum;
$isdispnum=$num-$artnumeof;
if($isdispnum<0){
$dispnumeof=$num;
$lesssign=1;
}
else{
$dispnumeof=$artnumeof;
}
$sign=0;
$pagec=0;
for($icount=0;($icount<$num)&&($sign==0);$icount+=6){
for($i=0;$i<=6;$i++){
if(($icount*6+$i)==$num){
$sign=1;
}
}
$pagec++;
}
$pagecount=$pagec;
$fuhao="◇ ";
$color=e9eae9;
$iscolor=0;
//$linkstr="disp_os.php?article_id=";
$lessnum=0;
for($i=$dispnumbeg;$i<$dispnumeof;$i++){
$partnum=intval($file1[$i]);
if($partnum==0){
$dispvar=$fuhao.$file[$i];
echo"<tr><td bgcolor=$color>";
echo $dispvar;
echo"</td></tr>";
$lessnum++;
}
else{
$linkstr=$dispstr[$partnum];
$linknum=$file2[$i];
$lessnum++;
$link=$linkstr.$linknum;
$dispvar=$fuhao.$file[$i];
echo"<tr><td bgcolor=$color>";
echo"<a href=$link>$dispvar</a>";
echo"</td></tr>";
}
if($iscolor==0){
$color=ffffff;
$iscolor=1;
}
else{
$color=e9eae9;
$iscolor=0;
}
}
if($lesssign==1){
for($iless=$lessnum;$iless<=5;$iless++){
echo"<tr bgcolor=$color><td>";
echo $fuhao."<br>n";
echo"</td></tr>";
if($iscolor==0){
$color=ffffff;
$iscolor=1;
}
else{
$color=e9eae9;
$iscolor=0;
}
}
}
echo"</table>";
?>