aspcms免费开源企业网站开发建设管理系统源码程序

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3736|回复: 0

ASPCMS多条件查询

[复制链接]

187

主题

188

帖子

609

积分

高级会员

Rank: 4

积分
609
发表于 2021-5-1 22:16:16 | 显示全部楼层 |阅读模式
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 StartDim typeStr: typeStr=""Dim searchTypesearchType=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" Thensql="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&orderStrElseDim formInput, keyValue, tempString : tempString = ""For Each formInput In Request.QueryStringIf Not formInput = "searchType" And Not formInput = "keys" And Not formInput = "page"  ThenkeyValue = filterPara(getForm(formInput, "get"))If Len(keyValue) > 0 And Len(filterPara(formInput)) > 0  ThentempString = tempString & " and " & formInput & " like '%" & keyValue & "%'"End IfEnd IfNexttempString = 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&orderStrEnd 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 FunctionElseDim formInput, keyValue, tempString : tempString = ""For Each formInput In Request.QueryStringIf Not formInput = "searchType" And Not formInput = "keys" And Not formInput = "page" ThenkeyValue = filterPara(getForm(formInput, "get"))If Len(keyValue) > 0 And Len(filterPara(formInput)) > 0 ThentempString = tempString & "&" & formInput & "=" & keyValueEnd IfEnd IfNextconditionSearch = tempStringExit Function'        strPageNumber=strPageNumber&"<a href=""?page="&pagenumber&"&keys="&keys&"&searchType="&searchtype&tempString&""">"&pagenumber&"</a>"End IfEnd 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 StartfirstPageLink="<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日
回复

使用道具 举报

*滑块验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|aspcms免费开源企业网站开发建设管理系统源码程序 ( 冀ICP备17022052号-2|网站地图

GMT+8, 2024-4-26 00:46 , Processed in 0.040960 second(s), 19 queries .

Powered by aspcms免费开源企业网站开发建设管理系统源码程序

© 2001-2025 aspcms免费开源企业网站开发建设管理系统源码程序

快速回复 返回顶部 返回列表