ASPCMS 多条件查询

1. 表单样例:

                <form name="topFrm"  id="topFrm" action="/search.asp">
                    <input name="searchType" type="hidden" value="3" id="searchType" />
                    <input name="keys" type="hidden" value="all" id="keys" />
                    <div class="search-li">
                        <input name="Title" type="text" class="search-input" id="Title" />
                        <span>项目名称:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_Area" type="text" id="P_Area" />
                        <span>区域:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_Room" type="text" id="P_Room" />
                        <span>房型:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_Cost" type="text" id="P_Cost" />
                        <span>造价:</span></div>
                    <div class="search-li">
                        <input class="search-input" name="P_DesignStyle" type="text" id="P_DesignStyle" />
                        <span>风格:</span></div>
                    <div class="search-btn"><a  href="javascript:topsearchSubmit();"><img src="{aspcms:sitepath}/Templates/{aspcms:defaulttemplate}/images/search_btn.gif" /></a></div>
                </form>
<script type="text/javascript">
    function topsearchSubmit()
    {
        topFrm.submit();
        return false;
    }
</script>

2. 修改"/inc/AspCms_MainClass.asp",修改查询语句(在源码的1484行)

‘ASPCMS Start
‘                    dim typeStr: typeStr=""
‘                    dim searchType
‘                    searchType=filterPara(getForm("searchType","get"))
‘                    if isnul(searchType) then searchType="0"
‘                    if  not "0"=searchType  then typeStr=" and a.SortID in (select {prefix}Sort.sortid from {prefix}Sort where sortType="&searchType&") "
‘                    sql="select ContentID,a.SortID,a.GroupID,a.Exclusive,Title,Title2,TitleColor,IsOutLink,OutLink,Author,ContentSource,ContentTag,Content,ContentStatus,IsTop,Isrecommend,IsImageNews,IsHeadline,IsFeatured,ContentOrder,IsGenerated,Visits,a.AddTime,a.[ImagePath],a.IndexImage,a.DownURL,a.PageFileName,a.PageDesc,SortType,SortURL,SortFolder,SortFileName,SortName,ContentFolder,ContentFileName,b.GroupID "&sperStr&" from {prefix}Content as a,{prefix}Sort as b where a.LanguageID="&setting.languageID&"and a.SortID=b.SortID and ContentStatus=1 and TimeStatus=0 and a.SortID in ("&getSubSort(typeIds, 1)&") and Title like ‘%"&keys&"%‘"&typeStr&orderStr
‘ASPCMS End

把上面修改成:

‘Feva Start
Dim typeStr: typeStr=""
Dim searchType
searchType=filterPara(getForm("searchType","get"))
If isnul(searchType) Then searchType="0"
If Not "0"=searchType  Then typeStr=" and a.SortID in (select {prefix}Sort.sortid from {prefix}Sort where sortType="&searchType&") "
If Not keys="all" Then
    sql="select ContentID,a.SortID,a.GroupID,a.Exclusive,Title,Title2,TitleColor,IsOutLink,OutLink,Author,ContentSource,ContentTag,Content,ContentStatus,IsTop,Isrecommend,IsImageNews,IsHeadline,IsFeatured,ContentOrder,IsGenerated,Visits,a.AddTime,a.[ImagePath],a.IndexImage,a.DownURL,a.PageFileName,a.PageDesc,SortType,SortURL,SortFolder,SortFileName,SortName,ContentFolder,ContentFileName,b.GroupID "&sperStr&" from {prefix}Content as a,{prefix}Sort as b where a.LanguageID="&setting.languageID&"and a.SortID=b.SortID and ContentStatus=1 and TimeStatus=0 and a.SortID in ("&getSubSort(typeIds, 1)&") and Title like ‘%"&keys&"%‘"&typeStr&orderStr
Else
    Dim formInput, keyValue, tempString : tempString = ""
    For Each formInput In Request.QueryString
        If Not formInput = "searchType" And Not formInput = "keys" And Not formInput = "page"  Then
            keyValue = filterPara(getForm(formInput, "get"))
            If Len(keyValue) > 0 And Len(filterPara(formInput)) > 0  Then
                tempString = tempString & " and " & formInput & " like ‘%" & keyValue & "%‘"
            End If
        End If
    Next
    tempString = tempString & " "
    sql="select ContentID,a.SortID,a.GroupID,a.Exclusive,Title,Title2,TitleColor,IsOutLink,OutLink,Author,ContentSource,ContentTag,Content,ContentStatus,IsTop,Isrecommend,IsImageNews,IsHeadline,IsFeatured,ContentOrder,IsGenerated,Visits,a.AddTime,a.[ImagePath],a.IndexImage,a.DownURL,a.PageFileName,a.PageDesc,SortType,SortURL,SortFolder,SortFileName,SortName,ContentFolder,ContentFileName,b.GroupID "&sperStr&" from {prefix}Content as a,{prefix}Sort as b where a.LanguageID="&setting.languageID&"and a.SortID=b.SortID and ContentStatus=1 and TimeStatus=0 and a.SortID in ("&getSubSort(typeIds, 1)&")"& tempString &typeStr&orderStr
End If
‘Feva End

3. 修改"/inc/AspCms_CommonFun.asp",添加函数:

‘Feva Start
‘多条件分页使用
Function conditionSearch()
    Dim keys : keys =  filterPara(getForm("keys", "get"))
    If Not keys="all" Then
‘            strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchtype="&searchtype&""">"&pagenumber&"</a>"
            conditionSearch = ""
            Exit Function
    Else
        Dim formInput, keyValue, tempString : tempString = ""
        For Each formInput In Request.QueryString
            If Not formInput = "searchType" And Not formInput = "keys" And Not formInput = "page" Then
                keyValue = filterPara(getForm(formInput, "get"))
                If Len(keyValue) > 0 And Len(filterPara(formInput)) > 0 Then
                    tempString = tempString & "&" & formInput & "=" & keyValue
                End If
            End If
        Next
        conditionSearch = tempString
        Exit Function
‘        strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchType="&searchtype&tempString&""">"&pagenumber&"</a>"
    End If
End Function
‘Feva End

3. 修改"/inc/AspCms_CommonFun.asp",分页中部函数 Function makePageNumber(Byval currentPage,Byval pageListLen,Byval totalPages,Byval linkType,Byval sortid, Byval showType) 修改:

‘ASPCMS  Start
‘                strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchtype="&searchtype&""">"&pagenumber&"</a>"
‘ASPCMS  End

修改成:

‘Feva Start
‘注意searchType大小写问题
                strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchType="&searchtype& conditionSearch() &""">"&pagenumber&"</a>"
‘Feva End

4. 修改"/inc/AspCms_CommonFun.asp",分页两侧函数 Function pageNumberLinkInfo(Byval currentPage,Byval pageListLen,Byval totalPages,Byval linkType,Byval sortid, Byval showType) 修改

‘ASPCMS Start
‘            firstPageLink="<a href=‘?page=1&keys="&keys&"&searchtype="&searchtype&"‘>"&str_01&"</a>" : lastPagelink="<a href=‘?page="&currentPage-1&"&keys="&keys&"&searchtype="&searchtype&"‘>"&str_03&"</a>"
‘ASPCMS End

修改成:

‘Feva Start
            firstPageLink="<a href=‘?page=1&keys="&keys&"&searchType="&searchtype&conditionSearch& "‘>"&str_01&"</a>" : lastPagelink="<a href=‘?page="&currentPage-1&"&keys="&keys&"&searchType="&searchtype&conditionSearch&"‘>"&str_03&"</a>"
‘Feva End            

大功告成了,试过,没有错误 ASPCMS 2.5.4 beta 2  2014年7月28日

时间: 2024-10-12 17:25:20

ASPCMS 多条件查询的相关文章

C# 将Access中时间段条件查询的数据添加到ListView中

C# 将Access中时间段条件查询的数据添加到ListView中 一.让ListView控件显示表头的方法 在窗体中添加ListView 空间,其属性中设置:View属性设置为:Detail,Columns集合中添加表头中的文字. 二.利用代码给ListView添加Item. 首先,ListView的Item属性包括Items和SubItems.必须先实例化一个ListIteView对象.具体如下: ListViewItem listViewItem=new ListViewItem(); l

php 多条件查询 例子

<hl>表单的多条件查询</h1> <form action="这个表.php" method="post"> <div> 请输入查询的名字:<input type="text" name="name" /> 请输入查询址性别:<input type="text" name="sex" /> <input ty

Django-rest-framework多条件查询/分页/多表Json

Django-rest-framework多条件查询/分页/多表Json django-rest-framework多条件查询需要覆写ListAPIView.get_queryset方法,代码示例: def get_queryset(self):     """     使用request.query_params实现多条件查询,也可以使用django filter ,较简单的     方法是在filter_fields中指定要过滤的字段,但只能表示等值,不灵活,灵活的方式是

基于Solr的HBase多条件查询测试

转自:http://www.cnblogs.com/chenz/articles/3229997.html 背景: 某电信项目中采用HBase来存储用户终端明细数据,供前台页面即时查询.HBase无可置疑拥有其优势,但其本身只对rowkey支持毫秒级的快速检索,对于多字段的组合查询却无能为力.针对HBase的多条件查询也有多种方案,但是这些方案要么太复杂,要么效率太低,本文只对基于Solr的HBase多条件查询方案进行测试和验证. 原理: 基于Solr的HBase多条件查询原理很简单,将HBas

PHP 多条件查询之简单租房系统

注:这里只展示多条件查询页面,其余的增删该页面略过 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta ht

关键字查询和多条件查询

0616DBDA.class.php 代码 <?php /** * Created by PhpStorm. * User: Administrator * Date: 2016/6/16 * Time: 11:23 */ class DBDA { public $host="localhost";//服务器地址 public $uid="root" ;//用户名 public $pwd="";//密码 public $dbconnect;

PHP-----多条件查询

在开发网页时,用谷歌和火狐浏览器,会比较好.IE浏览器不是太好用. 多条件查询 拿汽车表car,来做例子. 先把car表查出来,用表格来显示,在加一些查询的条件进去. 第一步:把car表查出来,用表格来显示 <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>代号</td> <td

2016/3/13 七种查询 (普通查询 条件查询 排序查询 模糊查询 统计查询 分组查询 分页查询 )

一句话概括的话,SQL作为结构化查询语言,是标准的关系型数据库通用的标准语言: T-SQL 是在SQL基础上扩展的SQL Server中使用的语言 1,普通查询 #查询Info表中的所有列 select * from Info #查询Info表中的Name和Code列 select Name,Code from Info 2,条件查询 关键字where #查询Info表的左右列 限定范围 列名为p001 select * from Info where 列名="p001" #查询条件之

ThinkPHP中 按条件查询后列表显示

最近在项目中遇到了需要根据下拉框的条件筛选出符合条件的数据,然后进行列表显示的问题. 在ThinkPHP中进行列表显示的传统过程:通过在后台控制器中查询出数据,然后通过$this->assign()来实现控制器数据向页面的传递,在页面中通过<foreach>或<volist>标签来进行数据的解析,(注:在通过标签进行数据的解析时需要以“$”符号的形式). 在进行条件查询时,需要通过jquery中ajax的方式将条件GET到后台控制器,后台控制器中接收数据,然后根据条件进行查询