2013-01-31 158 views
-1

在傳統ASP網站和MSSQL數據庫中:搜索數據完成時,URL顯示結果的ID。例如sitename/Display_Results.asp?cboService = & cboRegion = 。腳本或代碼在哪裏確定ID的返回,它是否在頁面代碼或數據庫存儲過程中?我想在URL中顯示Id的描述。經典ASP返回URL中結果的ID

<%@ language="vbscript" codepage="1252"%> 
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

    <% 
    sRoot = ""` 





    Function alert(msg,where) 
    %> 
    alert('<%="Message = "&msg&"\nWhere = "&where%>') <% end function 

    fFunction Ceiling(byval n) Dim iTmp, bErr 

    on error resume next 
    n = cdbl(n) 
    if err then bErr = true 
    on error goto 0 

    if bErr then Err.Raise 5000, "Ceiling Function", _ 
    "Input must be convertible to a sub-type of double" 

    f = Floor(n) 
    if f = n then 
    Ceiling = n 
    Exit Function 
    End If 

    Ceiling = cInt(f + 1) 
     End Function 
     %> 


     <html> 

     <head> 

     <!--#include file="includes/scripts/Includes.asp"--> 

     <% 
    Call WriteServiceMetaData(objConn, strConn) 
     %> 

     <script type="text/javascript" src="includes/scripts/javascript.js"></script> 
     <script type="text/javascript" src="includes/scripts/pngfix.mod.js"></script> 
     <script type="text/javascript" src="includes/scripts/swfobject.js"></script> 
     <script type="text/javascript" src="swfobject/swfobject.js"></script> 
     <script type="text/javascript"> 

     function showborder(idnew,argsnew){ 

    var idnew = idnew; 
     var argsnew = argsnew; 
    if(argsnew == "on"){ 
    document.getElementById(idnew).style.border='2px solid #759fb9'; 
    } 
    else{ 
    document.getElementById(idnew).style.border=''; 
    } 

     } 
     </script> 
     <script type="text/javascript"> 
     function showpng(idnew,argsnew){ 
    var idnew = idnew; 
    var argsnew = argsnew; 
    if(argsnew == "on"){ 
    document.getElementById(idnew).style.visibility=''; 
    } 
    else{ 
    document.getElementById(idnew).style.visibility='hidden'; 
    } 

     } 
     </script> 


     <link rel="stylesheet" type="text/css" href="<%=sRoot%>css/universal.css"> 
     </head> 
     <% 
    Dim maxResults 
    Dim DRCountry_ID, Country_Variable 
    Dim DRCounty_ID, County_Variable 
    Dim DRLocation, Location_Variable 
    Dim DRType_ID, DRType_ID_Array, Type_Variable, cType_Variable 
    Dim End_request, LUXSQL 
    Dim Query, Query_Result 
    Dim Page_Num, HOTSQL, HOTOFFER, Text, DRTube_ID, DRPrice_Min, DRPrice_Max, Tube_Variable, DRPrice, Price_Variable 
     Dim lCityID, lCountyID, lCountryID 

    set objRS = objConn.execute ("General_Admin_List") 
    maxResults = objRS("Num_Results") 
    objRS.Close 
    set objRS = nothing 
    'on error resume next 
    'Page_Num= clng(Request.QueryString("Page_Num")) 
    'if err.number <> 0 then 
    'Page_Num = 0 
     'end if 
     'on error goto 0 
      if strcomp(Request.ServerVariables("REQUEST_METHOD"), "POST", 1) = 0 then 

     on error resume next 
     if len(trim(Request.Form("HotOffer"))) > 0 then 
    iHotOffer = 1 
     else 
    iHotOffer = 0 
     end if 




     on error resume next 
     'Turn off error handling 
     company = trim(request.Form("company")) 
     if company = "Enter Name" then 
    company = "" 
     end if 
     if err.number <> 0 then 
     'If there is an error then the requested input is not a number 
    company = "null" 
     end if 
     err.clear 
     'Turn error handling back on 
     on error goto 0 


     lCountyID = clng(trim(Request.Form("cboRegion"))) 
     if err.number <> 0 then 
    lCountyID = 0 
     end if 
     err.clear 

     lCountryID = clng(trim(Request.Form("cboCountry"))) 
     if err.number <> 0 then 
    lCountryID = 0 
     end if 
     err.clear 

     lFeatureID = clng(trim(Request.Form("cboFeature"))) 
     if err.number <> 0 then 
    lFeatureID = 0 
     end if 
     err.clear 

     lServiceID = clng(Request.Form("cboService")) 
     if err.number <> 0 or lServiceID < 1 then 
    lServiceID = 0 
     else   
    session("SearchServiceID") = lServiceID 

     end if 
     err.clear 

     lCityID = clng(Request.Form("cboCity")) 
     if err.number <> 0 or lCityID < 1 then 
    lCityID = 0 
     end if 


     sTypes = trim(Request.Form("asfTypes")) 
     session("searchTypes") = sTypes 
     on error goto 0 
      else 



     on error resume next 
     'Turn off error handling 
     company = trim(request.QueryString("company")) 
     if company = "Enter Name" then 
    company = "" 
     end if 
     if err.number <> 0 then 
     'If there is an error then the requested input is not a number 
    company = "null" 
     end if 
     err.clear 
     'Turn error handling back on 
     on error goto 0 

     on error resume next 
     if len(trim(Request.QueryString("HotOffer"))) > 0 then 
    iHotOffer = 1 
     else 
    iHotOffer = 0 
     end if 

     lCountyID = clng(trim(Request.QueryString("cboRegion"))) 
     if err.number <> 0 then 
    lCountyID = 0 
     end if 
     err.clear 
     lCountryID = clng(trim(Request.QueryString("cboCountry"))) 
     if err.number <> 0 then 
    lCountryID = 0 
     end if 
     err.clear 

     lFeatureID = clng(trim(Request.QueryString("cboFeature"))) 
     if err.number <> 0 then 
    lFeatureID = 0 
     end if 
     err.clear 

     lServiceID = clng(Request.QueryString("cboService")) 

     if err.number <> 0 or lServiceID < 1 then 
    lServiceID = 0 
     else 
    session("SearchServiceID") = lServiceID 

     end if 
     err.clear 

     if request.QueryString("asfFeatures") <> "" then 
    lFeatureID = clng(Request.QueryString("asfFeatures")) 
    if err.number <> 0 or lFeatureID < 1 then 
     lFeatureID = 0 
    end if 
    err.clear 
     end if 

     lCityID = clng(Request.QueryString("CityID")) 
     if err.number <> 0 or lCityID < 1 then 
    lCityID = 0 
     end if 

     sTypes = trim(Request.QueryString("asfTypes")) 
     'Response.Write(sTypes) 
     session("searchTypes") = sTypes 
     on error goto 0 


      end if 


      if lCityID = 0 then 
     sCity = trim(Request.QueryString("City")) 
     if len(sCity) = 0 then 
    lCityID = 0 
     else 
    set objRS = objConn.execute ("City_Lookup '" & Replace(sCity, "'", "''") & "'") 
    if objRS.EOF then 
     lCityID = 999999 
    else 
     lCityID = objRS("City_ID") 
     lCountyID = objRS("County_ID") 
     lCountryID = objRS("Country_ID") 
    end if 
    objRS.Close 
    set objRS = nothing 
     end if 
      end if 
      'This below was commented out, seems to do nothing 
     ' Not using location finder just yet 
     dim sURL 
      sURL = "Select_Location.asp?location=" & Server.URLEncode(trim(Request.QueryString("SLocation"))) & "&Search=" & Request.QueryString("Search") 
      sURL = sURL & "&Service=" & lServiceID 
      sURL = sURL & "&Types=" & sTypes 
     DRLocation = replace(trim(Request.QueryString("SLocation")), "'", "''") 
     if len(DRLocation) > 0 then ' and lCountryID = 0 then 
    set objRS = Server.CreateObject("ADODB.Recordset") 
    objRS.CursorLocation = 3 
    objRS.Open "City_Lookup '" & DRLocation & "'," & lCountyID & ", " & lCountryID, objConn 
     if objRS.RecordCount > 1 then 
     objRS.Close 
     objConn.close 
     response.Redirect(sURL) 
     end if 
     if not objRS.eof then 
     lCityID = clng(objRS("City_ID")) 
     lCountyID = clng(objRS("County_ID")) 
     else 
     objRS.Close 
     objRS.Open "County_Lookup '" & DRLocation & "', " & lCountryID, objConn 
      if objRS.RecordCount > 1 then 
      objRS.Close 
      objConn.close 
      response.Redirect(sURL) 
     end if 
     if not objRS.eof then 
      lCountyID = clng(objRS("County_ID")) 
     else 
      objRS.Close 
      objConn.close 
      response.Redirect(sURL) 
     end if 
       end if 


     objRS.Close 
     set objRS = nothing 
     end if 
    'This above was commented out, seems to do nothing 
     dim lSearchID 
     lSearchID = 0 

     if len(sTypes) > 0 then 
     Application.Lock() 
     if Application("LSG_SearchID") = "" then 
      lSearchID = 1 
     else 
      lSearchID = clng(Application("LSG_SearchID")) + 1 
     end if 
     Application("LSG_SearchID") = lSearchID 
     Application.UnLock() 
     objConn.execute "Value_Splitter '" & sTypes & "', ',', " & lSearchID 
    end if 

    objConn.CursorLocation = adUseClient 
    set objComm = Server.CreateObject("ADODB.Command") 
    set objComm.ActiveConnection = objConn 
    objComm.CommandText = "Search" 
    objComm.CommandType = adCmdStoredProc 
    objComm.Parameters.Append objComm.CreateParameter ("@City_ID", adInteger, adParamInput) 
    objComm.Parameters.Append objComm.CreateParameter ("@County_ID", adInteger, adParamInput) 
    objComm.Parameters.Append objComm.CreateParameter ("@Country_ID", adInteger, adParamInput) 
    objComm.Parameters.Append objComm.CreateParameter ("@Service_ID", adInteger, adParamInput) 
    objComm.Parameters.Append objComm.CreateParameter ("@Search_ID", adInteger, adParamInput) 
    objComm.Parameters.Append objComm.CreateParameter ("@Feature_ID", adInteger, adParamInput) 
    objComm.Parameters.Append objComm.CreateParameter ("@Specialist_Area", adBoolean, adParamInput, , iHotOffer) 
    objComm.Parameters.Append objComm.CreateParameter ("@ResultCount", adInteger, adParamOutput) 
    objComm.Parameters.Append objComm.CreateParameter ("@Company", adVarchar, adParamInput, 255) 

    if lCountryID > 0 then 
     objComm.Parameters("@Country_ID") = lCountryID 
    end if 
    if lCountyID > 0 then 
     objComm.Parameters("@County_ID") = lCountyID 
    end if 
    if lCityID > 0 then 
     objComm.Parameters("@City_ID") = lCityID 
    end if 
    if lServiceID > 0 then 
     objComm.Parameters("@Service_ID") = lServiceID 
    end if 
    if lFeatureID > 0 then 
     objComm.Parameters("@Feature_ID") = lFeatureID 
    end if 
    if lSearchID > 0 then 
     objComm.Parameters("@Search_ID") = lSearchID 
    end if 

    if company = "null" then 
     objComm.Parameters("@Company") = null 
    else 
     objComm.Parameters("@Company") = company 
    end if 

    'Query = "Search " & paramCity & ", " & paramCounty & ", " & paramCountry 
'end if 

     'response.End() 
     'Set Query_Result = Server.CreateObject("ADODB.Recordset") 
     'Response.Write("Query"&Query) 
     set Query_Result = objComm.Execute() 
     lResultCount = objComm.Parameters("@ResultCount").value 
     lSearchCity = lCityID 



     if lServiceID > 0 then 

     SELECT_SQL = "Service_Get "& lServiceID 
    Set SELECT_SQL_RESULT = Server.CreateObject("ADODB.Recordset") 
     SELECT_SQL_RESULT.Open SELECT_SQL, ObjConn 
    do while not SELECT_SQL_RESULT.eof 
    service = SELECT_SQL_RESULT("service") 
    service_description = SELECT_SQL_RESULT("Service_Description") 
     SELECT_SQL_RESULT.MoveNext 
    Loop 
     SELECT_SQL_RESULT.Close 
     end if    


      'Get city (set email location) from search and put into cookie 
     if Request.QueryString("CityID") > 0 Then 
    GetCity = "getCity "&Request.QueryString("CityID") 
    Set GetCity_Result = Server.CreateObject("ADODB.Recordset") 
    GetCity_Result.Open GetCity, ObjConn 
    if not GetCity_Result.eof then 
     emailCity = GetCity_Result("City") 
    end if 
    Response.Cookies("LSG")("Location") = emailCity 
    Response.Cookies("LSG").Expires= DateAdd("d", Date(), 365) 
     end if 
      %> 
      <% 
      Dim SELECT_SQL, SELECT_SQL_RESULT 
      Dim Top_PAGECONTENT_Title, Top_PAGECONTENT_Content 
      Dim Bottom_PAGECONTENT_Title, Bottom_PAGECONTENT_Content 

      Dim page_name, url,sPath 
      sPath="" 
      url = request.ServerVariables("URL") 
      page_name = right(url, len(url) - instrrev(url, "/")) 

      SELECT_SQL = "Page_Content_Get '"& page_name &"'" 
      Set SELECT_SQL_RESULT = Server.CreateObject("ADODB.Recordset") 
      SELECT_SQL_RESULT.Open SELECT_SQL, ObjConn 

      do while not SELECT_SQL_RESULT.eof 
     If SELECT_SQL_RESULT("Position") = "Page Top" then 
    Top_PAGECONTENT_Title = SELECT_SQL_RESULT("Title") 
    Top_PAGECONTENT_Content = SELECT_SQL_RESULT("Content") 
    Top_PAGECONTENT_Content = Replace(Top_PAGECONTENT_Content, vbcrlf, "<br>") 
     end if 
     SELECT_SQL_RESULT.MoveNext 
      Loop 
      SELECT_SQL_RESULT.Close 
      %> 


       <body> 
      <div class="SiteContainer"> 
      <!--#include file="includes/content/banner_rotator.asp"--> 
     <div class="LeftSiteContainer"> 
     <!--#include file="includes/content/hdg_left.asp"--> 
     <!--#include file="includes/content/hdg_Header2.asp"--> 
     <div class="indexMainContainer"> 
      <div id="mainLeftContent"> 

       <div class="MainContent">     

        <%       
         if service = "" then 
          service = "Boat and Yacht products and services" 
         end if 
         if emailcity = "" then 
          emailcity = "Boat Chandlers Guide" 
         end if 
        %> 
      <%If not Query_Result.EOF Then%> 
         <span style="color:#1A59CD;"><h1><%=service%></h1></span> 
         <span style="color:#1A59CD;"><h2><%=Service_Description%></h2></span> 
         <div style="color:#666666; float:left; padding-top:8px;">Your search returned <span style="color:#1A59CD; font-weight:bold;"><%=lResultCount%></span> result<%if lResultCount > 1 then response.write "s" end if%> for <!--<%=emailcity%> to--> <%=service%> </div>  
         <div style="clear:both;"> </div>&nbsp;             
         <!--<h2><%=emailcity%> search results for <%=service%></h2>--> 
        <% else %> 
         <div style="clear:both;"></div>&nbsp; 
         <span style="color:#1A59CD;"><h1><%=emailcity%> <%=service%></h1></span> 
          <div class="search_no_results">       
          <strong>Sorry, there are currently no <%=service%> featured on <%=emailcity%> at this time.</strong> 
         </div> 
        <% End If %> 
       <%If not Query_Result.EOF Then 
        numResults = maxResults 'The Number of Results to Display on each page      
        count = lResultCount       
        dim Number_array, Total_Pages 
        Number_Array = split(((count-1)/numResults),".")      
        Total_Pages = count \ numResults        
        if count mod numResults > 0 then 
         Total_Pages = Total_Pages + 1 
        end if 
        %>      
       <%end if 

       If Query_Result.EOF Then%> 
        <div class="search_no_results"> 
         <strong>Sorry, no results were found that match your search criteria.</strong> 
        </div> 
       <% End If 

       Dim count, strt, endd, numResults, tr_count 
       tr_count = 0 
       '-----------------------------------------------' 
       ' Set the Number of the first record to display ' 
       '-----------------------------------------------' 
       if not Query_Result.eof then 
        strt = cint(Request.queryString("results")) 
        if (strt = null) OR (strt <= 0) then 
         strt = 1 
        end if 
        endd = strt + numResults-1 
        if numresults = 1 then 
         Page_Num = strt 
        else 

         Page_Num = strt \ numresults 
         Page_Num = Page_Num + 1 
        end if 
       end if 
       count = 1 

       PageEnd = Page_Num * numResults 
       PageStart = PageEnd - 20  
       if PageEnd > lResultCount then 
        pageEnd = lResultCount         
       end if 

       if request.QueryString("st") = "" then 
        CurrentPageNumber = 1 
       else 
        CurrentPageNumber = request.QueryString("st") 
       end if 

       'How many on first number 
       FirstNum = numResults * (CurrentPagenumber - 1) - (numResults -1)        
       if clng(CurrentPageNumber) < clng(Total_Pages) then            
        if clng(Total_Pages - 1) = clng(CurrentPageNumber) then 
         high = CurrentPageNumber + 1 
        else 
         high = CurrentPageNumber + 2 
        end if     
       end if 

       'How many on last number 
       LastNum = numResults * (CurrentPagenumber + 1) - (numResults-1)            
       LastCount = ((Total_Pages - 1) * numResults) + 1 

       if lResultCount > 0 then%> 
        <DIV class="displayResultsPageNumberContainer">           
         <div class="displayResultsPrevious">         
          <% if Page_Num > 1 then %> 
           <A id="Page<%=PageNumber%>" style="color:#6b98b4;" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&results=<%=FirstNum%>&st=<%=CurrentPagenumber-1%>"><<Previous</A>   
          <% else %> 
           &nbsp;        
          <% end if %> 
         </div> 

         <% if cint(Page_Num) < cint(Total_Pages) then 
          %>         
          <div style="float:right; margin-right:10px;"><A style="color:#6b98b4;" id="Page<%=PageNumber%>" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&st=<%=CurrentPagenumber+1%>&results=<%=LastNum%>">Next >></a></div> 
         <% end if %>    
        </DIV> 
       <%end if 


       Do Until Query_Result.EOF or count > endd 
        if (count >= strt) AND (count <= endd) then 
         Image_Query = "Advert_Images_Get "&Query_Result("Advert_ID") 
         Set Image_Query_Result = Server.CreateObject("ADODB.Recordset") 
         Image_Query_Result.Open Image_Query, ObjConn 
         if not Image_Query_Result.eof then 
          ImgThumb = replace(Image_Query_Result("Image_Name"),".jpg","_db_mid.jpg") 

         else 
          ImgThumb = "1pxSpacer.gif" 
         end if 

         %> 
         <div class="search_result_advert"> 
          <% newCity = replace(Query_Result("City"),",","_") %> 
          <div class="search_result_advert_img"> 
           <div><a title="View Advert - <%=Query_Result("Title")%>" href="<%=getFilename(newCity, Query_Result("Title"), Query_Result("Advert_ID"))%>"><img src="adverts_pics/<%=ImgThumb%>" alt="<%=Query_Result("Title")%>" border="0" /></a></div>        
          </div> 
          <div class="search_result_advert_details"> 
           <div style="float:right;"><a style="color:#6b98b4;" title="View Advert - <%=Query_Result("Title")%>" href="<%=getFilename(newCity, Query_Result("Title"), Query_Result("Advert_ID"))%>">More Info</a></div> 
           <h3><a id="Result<%=Query_Result("Advert_ID")%>" title="View Advert - <%=Query_Result("Title")%>" href="<%=getFilename(newCity, Query_Result("Title"), Query_Result("Advert_ID"))%>"><%=ucase(TruncateString(Query_Result("Title"),30))%></a></h3>              
           <div style="margin-top:5px;"><%=TruncateString(Query_Result("Description"), 320)%></div> 
          </div>       
         </div> 
         <div style="margin-top:10px; height:5px;"></div> 
         <% 
        end if 
        count = count + 1 
        Query_Result.MoveNext 
       Loop 


       %> 

       <%if lResultCount > 0 then%> 
        <DIV class="displayResultsPageNumberContainer">           
         <div class="displayResultsPrevious">         
          <% if Page_Num > 1 then %> 
           <A style="color:#6b98b4;" id="Page<%=PageNumber%>" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&results=<%=FirstNum%>&st=<%=CurrentPagenumber-1%>"><< Previous</A>    
          <% else %> 
           &nbsp;       
          <% end if %> 
         </div> 
         <!--<div class="displayResultsPageNumber">Displaying <b><%=PageStart%> - <%=PageEnd%> of <%=lResultCount%> Search Results for </b></div>--> 
         <% if cint(Page_Num) < cint(Total_Pages) then 
          %>         
          <div style="float:right; margin-right:10px;"><A style="color:#6b98b4;" id="Page<%=PageNumber%>" href="Display_Results.asp?cboCountry=<%=lCountryID%>&cboFeature=<%=request.QueryString("cboFeature")%>&cboRegion=<%=lCountyID%>&cboService=<%=lServiceID%>&asfTypes=<%=sTypes%>&CityID=<%=lSearchCity%>&asfFeatures=<%=lFeatureID%><%if iHotOffer > 0 then response.Write("&HotOffer=Y") end if%>&st=<%=CurrentPagenumber+1%>&results=<%=LastNum%>">Next >></a></div> 
         <% end if %>    
        </DIV> 
       <%end if%> 

       <br/> 
       <br/> 
       <div class="advanced_bg"> 
        <div style="float:left;"><img src="images/img_advanced.jpg" alt="Advanced Search"/></div> 
        <div id="advanced_title"> <%=Top_PAGECONTENT_Title%></div> 
        <%=Top_PAGECONTENT_Content%> 
       </div>  

      </div> 
      <% 
      '<!--#include file="includes/content/hdg_right.asp"--> 
      %> 
     </div> 
    </div>  
    <div id="footer"><!--#include file="includes/content/hdg_Footer.asp"--> </div> 
</div> 
        </body> 
         </html> 
         <!--#include file="includes/scripts/DatabaseConnectClose.asp"--> 
+0

如何回覆您的答案? – SelfTaught

回答

0

沒有你顯示的代碼,這將是很難確定到底是怎麼回事,但我最好的猜測是,你的表格方式設置爲「搞定」,而不是「後」。

正因如此,所有這些值對都顯示在URL中。 此外,你想要在那裏的身份證,這可能是目前在一個隱藏的領域?

+0

感謝Guru,這是「Display_result.asp」中頭標籤之間的代碼。請注意,某些代碼可能與我繼承此網站時不相關。 – SelfTaught

+0

你可以粘貼整個頁面的源代碼請 – SQLGuru

+0

嗨大師,我試過了,但這個評論框不會讓我粘貼那麼多的文字? – SelfTaught