人大复印资料处理程序_查询篇


Posted in PHP onOctober 09, 2006

<?
//本程序为一个搜索,目前设计服务于文章库。
//编者:孔秀祥。日期:2001/4/10
if(!$UploadAction):
require "config.php3";
if(!isset($table)){
//$table="artical";
}
/*
$link_id=@MYSQL_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("不能连接数据库!");
@mysql_select_db("$dbname") or die("不能选择数据库!");
$q="select count(id) from $table where 1 ";
$result = @mysql_query($q);
$row = @mysql_fetch_array($result);
  $r_count=$row["count(artical_id)"];
*/   

?>
<HTML><HEAD><TITLE>数据库搜索 </TITLE>
</HEAD>
<BODY><table align=center cellpadding="0" cellspacing="0" width="420" style="border-style:outset; border-bottom-width:thin; border-left-width:thin;border-right-width:thin;border-top-width:thin; border-color:#fefefe;">
<TH colspan=2 bgcolor=726cc5>
<!--tr><td colspan=2 bgcolor=726cc5-->
<font color=white face=Arial,Helvetica size=2>
<CENTER>
本程序运行较费时间,需要耐心等待。</TH>

<FORM ENCTYPE= "multipart/form-data" NAME = "SubmitForm"
ACTION= "<? $PHP_SELF ?>" METHOD = "POST">
<!--INPUT TYPE= "hidden" NAME = "MAX_FILE_SIZE" VALUE ="2500000"-->
<INPUT TYPE= "hidden" NAME = "UploadAction" VALUE = "1">
<INPUT TYPE= "hidden" NAME = "table" VALUE = "<? echo $table; ?>" >
<input type="hidden" name=table value="artical">
<tr  border=1><td colspan=2 align=center>查询项目
<tr><td colspan=2 align=center><input type="radio" name=a_data value="data" checked>文章内容
<input type="radio" name=a_data value="title">文章标题
<input type="radio" name=a_data value="author">文章作者
<input type="radio" name=a_data value="month" >期刊名
<!--input type="radio" name=a_data value="type" >分类号<BR-->
<TR><TD>搜索内容<TD><INPUT NAME = "data_search" TYPE = "text" VALUE="" SIZE = "30"></TD>
<TR><TD>索引文件名<TD><INPUT NAME = "index_file" TYPE = "text" VALUE="" SIZE = "30"></TD>
<TR><TD>索引标题<TD><INPUT NAME = "index_title" TYPE = "text" VALUE="" SIZE = "30"></TD>
<!--TR><TD>从第<INPUT NAME = "s_id" TYPE = "text" VALUE="1" SIZE = "4"><td>
开始的<INPUT NAME = "step" TYPE = "text" VALUE="100" SIZE = "4">条,共有<? echo $r_count ?>条记录。</TD></TR-->
<TR><TD>文章分类</TD>
<TD>
<SELECT size="1" name="catalog" TYPE = "int">
?<OPTION selected value="11">语言理论</OPTION>
<OPTION value="21">历史学</OPTION>
<OPTION value="31">中国哲学</OPTION>
<OPTION value="41">其他</OPTION>
?<!--OPTION selected value="11">语言理论</OPTION-->
</SELECT>
</TR>
<TR><TD colspan=3 align=center>
<INPUT NAME = "submit" VALUE = "提交" TYPE = "submit">
<INPUT NAME = "reset" VALUE = "重置" TYPE = "reset"></TD>
</TD></TR>
</FORM></CENTER></TABLE></BODY>

</HTML>

<?

else:

require "config.php3";
$UploadAction=0;
$added=0;
$die=0;
$single_chinese=0;
$TimeLimit=0; /*设置超时限制时间缺省时间为 30秒设置为0时为不限时 */
set_time_limit($TimeLimit);

if($data_search==""){
//做全库的索引
header("location:\progs\data_index.php3");
//$msg="搜索内容不能为空。";
//xueroom_error_exit($msg,$PHP_SELF);
}

$link_id=@MYSQL_CONNECT($hostname,$dbusername,$dbpassword) OR DIE("不能连接数据库!");
@mysql_select_db("$dbname") or die("不能选择数据库!");
//SELECT id,file_name,artical_author from textfile where 1 LIMIT 0, 30   
if($table=="artical")
{
$sid="artical_id";
$stitle="artical_title";
$sauthor="artical_author";
$sdata="artical_data";
$prog="readfile.php3";
if($a_data=="month" )
    $key_where="where origin_periodical rlike '^.*$data_search.*'";
}
if($a_data=="data" )
    $key_where="where $sdata rlike '^.*$data_search.*'";
if($a_data=="title" )
    $key_where="where $stitle rlike '^.*$data_search.*'";
if($a_data=="author" )
    $key_where="where $sauthor rlike '^.*$data_search.*'";

//$q="select $sid,$stitle,$sauthor from $table where $sdata rlike '^.*$data_search.*'order by $stitle";
if(($a_data=="data")&&(strlen($data_search)==2)){
    $q="select $sid,$stitle,$sauthor,$sdata from $table $key_where order by $stitle";
    $single_chinese=1;
    }
else{
    $q="select $sid,$stitle,$sauthor from $table $key_where order by $stitle";
}
$index_data="";
$count=0;
$result =@ mysql_query($q);

if(!$result){
    $msg="没有符合要求的记录。";
    xueroom_error_exit($msg,$PHP_SELF);
}
while($row = @mysql_fetch_array($result)) {
  if(($single_chinese)&&(!myStrPos($row[$sdata],$data_search)))
  continue;
  else
  {
    $id=$row[$sid];
      $title=$row[$stitle];
      $author=$row[$sauthor];
      if($table=="textfile")
        $title=preg_replace("/.txt/","",$title);
//  $data=$row["artical_data"];
  //if(myStrPos($data,$data_search)) //可以用于寻找单个汉字。
//  if(strpos($data,$data_search)){  //大于一个汉字时采用本判断式,速度较快。
      $index_data.="<TR><TD><a href=".$dataurl."$prog?$sid=$id>$title</a><TD>作者:$author </TR>";
      $count++;
  //fputs($fp, "<TR><TD><a href=".$dataurl."readfile.php3?artical_id=$id>$title</a><TD>作者:$author </TR>");
// }
}
  }
@mysql_free_result($result);
mysql_close($link_id);
set_time_limit(30);
if($index_title==""){
$index_title="学而斋资料";
}
$index_title=$index_title."_".$data_search;

$html_header="<html><head><title>$index_title</title></head><body>";
$html_header.="<h5>$index_title</h5>rn";
$dte_created=date('Y-m-d H:i:s');
$html_header.="<font color='Maroon' face='楷体' size=1>$index_describe 发现了 $count 条/查询日期:$dte_created</font><hr>rn";
$html_header.="<table>rn";
$data=$html_header.$index_data;
$data.="<TABLE></body></html>";
/*If(strlen($index_file)==0){
header("Content-type: text/html");
   echo $data;
   }
   else
   {
$in_file="$index_file";
$index_file="\index\".$index_file;
$fp=indexfile($index_file,$index_title,$index_describe);
fputs($fp, "发现了 $count 条");
fputs($fp, "查询日期:$dte_created</font><hr>rn");
fputs($fp,"<table>rn");
fputs($fp, $index_data);
fputs($fp, "<TABLE></body></html>");
fclose($fp);
echo"点<a href=$index_url$in_file>这里</a>看新加入的文件索引<BR>";
   }
  */
If(strlen($index_file)!=0){
     $in_file="$index_file";
     $index_file="\index\".$index_file;
   }
else
       $in_file="temp.html";
$fp=indexfile($index_file,$index_title,$index_describe);
fputs($fp, "发现了 $count 条");
fputs($fp, "查询日期:$dte_created</font><hr>rn");
fputs($fp,"<table>rn");
fputs($fp, $index_data);
fputs($fp, "<TABLE></body></html>");
fclose($fp);

//    echo"点<a href=$index_url$in_file>这里</a>看新加入的文件索引<BR>";
header("location:$index_url$in_file");

    
//echo"索引文件为 $index_file";
echo"<BR><A HREF = $PHP_SELF>返回 </A>";

endif;
?> 

PHP 相关文章推荐
PHP常用函数小技巧
Sep 11 PHP
php 文件缓存函数
Oct 08 PHP
深入解析PHP的引用计数机制
Jun 14 PHP
PHP Class&amp;Object -- PHP 自排序二叉树的深入解析
Jun 25 PHP
如何让搜索引擎抓取AJAX内容解决方案
Aug 25 PHP
PHP统计数值数组中出现频率最多的10个数字的方法
Apr 20 PHP
php命令行(cli)模式下报require 加载路径错误的解决方法
Nov 23 PHP
详解WordPress开发中get_header()获取头部函数的用法
Jan 08 PHP
PHP按符号截取字符串的指定部分的实现方法
Sep 10 PHP
Yii框架日志操作图文与实例详解
Sep 09 PHP
PHP使用递归按层级查找数据的方法
Nov 10 PHP
PHP单元测试配置与使用方法详解
Dec 27 PHP
如何在PHP中使用Oracle数据库(1)
Oct 09 #PHP
BBS(php &amp; mysql)完整版(八)
Oct 09 #PHP
超级简单的发送邮件程序
Oct 09 #PHP
发挥语言的威力--融合PHP与ASP
Oct 09 #PHP
如何在PHP中使用Oracle数据库(2)
Oct 09 #PHP
用PHP连接Oracle for NT 远程数据库
Oct 09 #PHP
BBS(php &amp; mysql)完整版(六)
Oct 09 #PHP
You might like
JoshChen_php新手进阶高手不可或缺的规范介绍
2013/08/16 PHP
ThinkPHP后台首页index使用frameset时的注意事项分析
2014/08/22 PHP
php数组去除空值函数分享
2015/02/02 PHP
Joomla开启SEF的方法
2016/05/04 PHP
IE6背景图片不缓存问题解决方案及图片使用策略多个方法小结
2012/05/14 Javascript
jsvascript图像处理—(计算机视觉应用)图像金字塔
2013/01/15 Javascript
Tab切换组件(选项卡功能)实例代码
2013/11/21 Javascript
js中arguments,caller,callee,apply的用法小结
2014/01/28 Javascript
使用documentElement正确取得当前可见区域的大小
2014/07/25 Javascript
js实现点击图片将图片地址复制到粘贴板的方法
2015/02/16 Javascript
jQuery验证元素是否为空的两种常用方法
2015/03/17 Javascript
IE8 内存泄露(内存一直增长 )的原因及解决办法
2016/04/06 Javascript
使用 bootstrap modal遇到的问题小结
2016/11/09 Javascript
基于js中的存储键值对以及注意事项介绍
2018/03/30 Javascript
详解性能更优越的小程序图片懒加载方式
2018/07/18 Javascript
纯javascript前端实现base64图片下载(兼容IE10+)
2018/09/14 Javascript
js console.log打印对象时属性缺失的解决方法
2019/05/23 Javascript
element el-tree组件的动态加载、新增、更新节点的实现
2020/02/27 Javascript
JS如何生成随机验证码
2020/03/02 Javascript
vue使用openlayers实现移动点动画
2020/09/24 Javascript
Python的设计模式编程入门指南
2015/04/02 Python
浅析Python中将单词首字母大写的capitalize()方法
2015/05/18 Python
python生成式的send()方法(详解)
2017/05/08 Python
python enumerate函数的使用方法总结
2017/11/15 Python
Sanic框架基于类的视图用法示例
2018/07/18 Python
Python3中内置类型bytes和str用法及byte和string之间各种编码转换 问题
2018/09/27 Python
python求绝对值的三种方法小结
2019/12/04 Python
python实现对变位词的判断方法
2020/04/05 Python
浅析Python 中的 WSGI 接口和 WSGI 服务的运行
2020/12/09 Python
美国知名日用品连锁超市:Dollar General(多来店)
2017/01/14 全球购物
Europcar葡萄牙:葡萄牙汽车和货车租赁
2017/10/13 全球购物
五心教育心得体会
2014/09/04 职场文书
税务干部群众路线教育实践活动自我剖析材料
2014/09/21 职场文书
教师个人年终总结
2015/02/11 职场文书
销售内勤岗位职责范本
2015/04/13 职场文书
同学聚会祝酒词
2015/08/10 职场文书