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


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 cookie的操作实现代码(登录)
Dec 29 PHP
php字符串分割函数explode的实例代码
Feb 07 PHP
php源代码安装常见错误与解决办法分享
May 28 PHP
一个显示效果非常不错的PHP错误、异常处理类
Mar 21 PHP
CodeIgniter启用缓存和清除缓存的方法
Jun 12 PHP
ThinkPHP字符串函数及常用函数汇总
Jul 18 PHP
php将textarea数据提交到mysql出现很多空格的解决方法
Dec 19 PHP
php技术实现加载字体并保存成图片
Jul 27 PHP
php制作基于xml的RSS订阅源功能示例
Feb 08 PHP
PHP token验证生成原理实例分析
Jun 05 PHP
php输出文字乱码的解决方法
Oct 04 PHP
laravel 解决后端无法获取到前端Post过来的值问题
Oct 22 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
桌面中心(二)数据库写入
2006/10/09 PHP
生成随机字符串和验证码的类的PHP实例
2013/12/24 PHP
thinkphp3.2.2前后台公用类架构问题分析
2014/11/25 PHP
php创建、获取cookie及基础要点分析
2015/01/26 PHP
PHP+AjaxForm异步带进度条上传文件实例代码
2017/08/14 PHP
PHP常见的几种攻击方式实例小结
2019/04/29 PHP
php设计模式之状态模式实例分析【星际争霸游戏案例】
2020/03/26 PHP
JS 面向对象之神奇的prototype
2011/02/26 Javascript
Node.js中的事件驱动编程详解
2014/08/16 Javascript
jQuery超酷平面式时钟效果代码分享
2020/03/30 Javascript
JS当前页面登录注册框,固定DIV,底层阴影的实例代码
2016/09/29 Javascript
Vue.JS入门教程之自定义指令
2016/12/08 Javascript
Bootstrap源码解读排版(1)
2016/12/23 Javascript
javaScript基础详解
2017/01/19 Javascript
js评分组件使用详解
2017/06/06 Javascript
Angularjs实现控制器之间通信方式实例总结
2018/03/27 Javascript
vue2配置scss的方法步骤
2019/06/06 Javascript
Vue CLI3移动端适配(px2rem或postcss-plugin-px2rem)
2020/04/27 Javascript
vue实现下载文件流完整前后端代码
2020/11/17 Vue.js
解决vue使用vant轮播组件swipe + flex时文字抖动问题
2021/01/07 Vue.js
Python实现按学生年龄排序的实际问题详解
2017/08/29 Python
Python实现的生产者、消费者问题完整实例
2018/05/30 Python
Python+OpenCV图像处理——实现直线检测
2020/10/23 Python
python实现定时发送邮件
2020/12/23 Python
在PyCharm中安装PaddlePaddle的方法
2021/02/05 Python
顶级宝石首饰网络零售商:Angara
2016/10/25 全球购物
蛋白质世界:Protein World
2017/11/23 全球购物
Shopping happy life西班牙:以最优惠的价格提供最好的时尚配饰
2020/03/13 全球购物
校园广播稿500字
2014/02/04 职场文书
初中生自我鉴定
2014/02/04 职场文书
QQ空间主人寄语大全
2014/04/12 职场文书
法制宣传标语
2014/06/23 职场文书
2019自荐信范文集锦!
2019/07/03 职场文书
关于食品安全的演讲稿范文(三篇)
2019/10/21 职场文书
JVM入门之类加载与字节码技术(类加载与类的加载器)
2021/06/15 Java/Android
mysql优化之query_cache_limit参数说明
2021/07/01 MySQL