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


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 相关文章推荐
Wordpress php 分页代码
Oct 21 PHP
php中全局变量global的使用演示代码
May 18 PHP
PHP判断文件是否存在、是否可读、目录是否存在的代码
Oct 03 PHP
探讨:web上存漏洞及原理分析、防范方法
Jun 29 PHP
浅谈thinkphp的实例化模型
Jan 04 PHP
详解PHP的Yii框架中日志的相关配置及使用
Dec 08 PHP
php处理带有中文URL的方法
Jul 11 PHP
Yii框架防止sql注入,xss攻击与csrf攻击的方法
Oct 18 PHP
PHP实现上传图片到 zimg 服务器
Oct 19 PHP
PHP SFTP实现上传下载功能
Jul 26 PHP
PHP去除空数组且数组键名重置的讲解
Feb 28 PHP
php获取是星期几的的一些常用姿势
Dec 15 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
php中XMLHttpRequest(Ajax)不能设置自定义的Referer的解决方法
2011/11/26 PHP
PHP生成静态HTML页面最简单方法示例
2015/04/09 PHP
PHP读取大文件的几种方法介绍
2016/10/27 PHP
Ext第一周 史上最强学习笔记---GridPanel(基础篇)
2008/12/29 Javascript
jQuery 拖动层(在可视区域范围内)
2012/05/24 Javascript
JS按字节截取字符长度实例
2013/11/20 Javascript
导入extjs、jquery 文件时$使用冲突问题解决方法
2014/01/14 Javascript
Javascript非构造函数的继承
2015/04/27 Javascript
浅谈javascript中的闭包
2015/05/13 Javascript
jQuery获取页面及个元素高度、宽度的总结——超实用
2015/07/28 Javascript
JS实现网页顶部向下滑出的全国城市切换导航效果
2015/08/22 Javascript
AngularJS入门教程之 XMLHttpRequest实例讲解
2016/07/27 Javascript
浅谈Javascript中的12种DOM节点类型
2016/08/19 Javascript
ES6新特性五:Set与Map的数据结构实例分析
2017/04/21 Javascript
JS检测是否可以访问公网服务器功能代码
2017/06/19 Javascript
Element-UI踩坑之Pagination组件的使用
2018/10/29 Javascript
解决vue单页面修改样式无法覆盖问题
2019/08/05 Javascript
layui table 表格上添加日期控件的两种方法
2019/09/28 Javascript
Python编写电话薄实现增删改查功能
2016/05/07 Python
python实时分析日志的一个小脚本分享
2017/05/07 Python
Python计算时间间隔(精确到微妙)的代码实例
2019/02/26 Python
pytorch 加载(.pth)格式的模型实例
2019/08/20 Python
Django+uni-app实现数据通信中的请求跨域的示例代码
2019/10/12 Python
python 的numpy库中的mean()函数用法介绍
2020/03/03 Python
Opencv求取连通区域重心实例
2020/06/04 Python
Python过滤掉numpy.array中非nan数据实例
2020/06/08 Python
如何基于Python实现word文档重新排版
2020/09/29 Python
python 指定源路径来解决import问题的操作
2021/03/04 Python
HTML5上传文件显示进度的实现代码
2012/08/30 HTML / CSS
宝拉珍选美国官网:Paula’s Choice美国
2018/01/07 全球购物
美国豪华时尚女性精品店:Kirna Zabête
2018/01/11 全球购物
经典c++面试题二
2015/08/14 面试题
银行个人求职自荐信范文
2013/12/16 职场文书
校本教研工作制度
2014/01/22 职场文书
小学英语教学反思案例
2014/02/04 职场文书
优质服务心得体会(共4篇)
2016/01/22 职场文书