Need help w/search script

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Re: Need help w/search script

    Let me just start by saying that I am pretty new to ColdFusion, so bare with me
    cause some things just don't make sense. I think this is the part of the
    script that drives the pages:

    <cfparam name="FORM.item" default="">
    <cfparam name="PageNum_find" default="1">

    <cfset MaxRows_find=10>
    <cfset
    StartRow_find=Min((PageNum_find-1)*MaxRows_find+1,Max(find.RecordCount,1))>
    <cfset EndRow_find=Min(StartRow_find+MaxRows_find-1,find.RecordCount)>
    <cfset TotalPages_find=Ceiling(find.RecordCount/MaxRows_find)>
    <cfset QueryString_find=Iif(CGI.QUERY_STRING NEQ
    "",DE("&"&CGI.QUERY_STRING),DE(""))>
    <cfset tempPos=ListContainsNoCase(QueryString_find,"PageN um_find=","&")>
    <cfif tempPos NEQ 0>
    <cfset QueryString_find=ListDeleteAt(QueryString_find,tem pPos,"&")>
    </cfif>

    And I think it is this cfparam that makes it come up with different
    highlighted search terms: <cfparam name="PageNum_find" default="1">
    How can I make it so that it finds #FORM.item# in the next pages?

    EnergyFed Guest

  2. Similar Questions and Discussions

    1. Search a men for create a flash script for my personnal web site
      Hi i am search a conceptor for create for me a fireworks in Flash for my personnal web site contact me to list@nightrain.com thanks
    2. Help: CDML based script search yielding 0 records returns ALL of them.
      I have a database that from within FMPro 6, there's no problems. However when I transfer the simple command of doing scripted searches for certain...
    3. #25786 [NEW]: PHP website uses cookies to remember last search phrase in search box
      From: tipsen at imada dot sdu dot dk Operating system: - PHP version: Irrelevant PHP Bug Type: Unknown/Other Function Bug...
    4. PHP Search Script recommendations?
      Folks, Can anyone recommend a script which will add a search capability to my site pls? I need one which will work with PHP version 4.3.2...
    5. The Ultimate HTML Search Script. But.......!
      A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script...
  3. #2

    Default Re: Need help w/search script

    first, in that first code you posted, it has this: sHighLightKeyWords
    (result.ItemNumber, FORM.order)

    so the highlighter is looking for form.order, not form.item. is that a
    problem? I'm going to assume there's also a cfparam for form.order somewhere
    too, right?

    second, assuming that you do need to get form.item into the second page, try
    plugging this at the top of that code and see what happens:

    <cfparam name="URL.item" default="">
    <cfparam name="FORM.item" default="#URL.item#">

    now, this assumes that the back/next links pass the "item" attribute when you
    click them. i'm not sure if those links are doing that, however.

    oh, one more thing. i think you should take that cffunction out of the
    cfoutput and put it at the top of your page, unless there's something going on
    that i'm not seeing.

    good luck!

    jonnycattt Guest

  4. #3

    Default Re: Need help w/search script

    Actually, I posted too different pieces of code. Both of them are trying to do
    the same kind of search. For now lets stick to #Form.Item#. I added those
    cfparam but that did not seem to help.
    I think it does have to do with the links not passing the "item" attribute.
    It passes the FORM.item but does not highlight the search term. Here is my
    entire page (sorry I have to do this, cause it's long):

    <cfinclude template="../includes/include_CheckAuthority.cfm">
    <cfset datetime="<cfoutput>#CreateODBCDateTime(Now())#</cfoutput>">
    <cfparam name="FORM.item" default="">
    <cfparam name="URL.item" default="">
    <cfparam name="FORM.item" default="#URL.item#">
    <CFFUNCTION name="sHighLightKeyWords" returnType="string" output="no">
    <CFARGUMENT name="sRawText" type="string" required="Yes">
    <CFARGUMENT name="sListOfKeyWords" type="string" required="Yes">
    <CFARGUMENT name="sListDelimiter" type="string" default=" ">

    <CFSET var sProcessedText = sRawText>

    <CFLOOP list="#sListOfKeyWords#" index="sKeyWord"
    delimiters=#sListDelimiter#>
    <CFSET sProcessedText = ReplaceNoCase
    (
    sProcessedText,
    sKeyWord,
    '<span
    class="HighLighted">#sKeyWord#</span>',
    "ALL"
    )
    >
    </CFLOOP>
    <CFRETURN sProcessedText>
    </CFFUNCTION>


    <!--- Use CSS for cleaner, easier html. --->
    <CFOUTPUT>
    <style type="text/css">
    .HighLighted
    {
    background-color: yellow;
    }

    td.CenterCell
    {
    text-align: left;
    }
    </style>
    </CFOUTPUT>


    <!--- Note that it may be more efficient to save this entire loop's output
    using
    cfsavecontent, and then do the string replace only once.
    --->

    <cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
    <cfparam name="PageNum_find" default="1">
    <cfquery name="find" datasource="stuff">
    SELECT *
    FROM inven
    WHERE (0=0
    <CFLOOP list="%#FORM.item#%" index="thisword" delimiters=" ">
    AND (ItemNumb LIKE '%#thisword#%' OR ItemDisc LIKE '%#thisword#%')
    </CFLOOP>)
    ORDER BY ItemNumb ASC
    </cfquery>

    <cfset MaxRows_find=10>
    <cfset
    StartRow_find=Min((PageNum_find-1)*MaxRows_find+1,Max(find.RecordCount,1))>
    <cfset EndRow_find=Min(StartRow_find+MaxRows_find-1,find.RecordCount)>
    <cfset TotalPages_find=Ceiling(find.RecordCount/MaxRows_find)>
    <cfset QueryString_find=Iif(CGI.QUERY_STRING NEQ
    "",DE("&"&CGI.QUERY_STRING),DE(""))>
    <cfset tempPos=ListContainsNoCase(QueryString_find,"PageN um_find=","&")>
    <cfif tempPos NEQ 0>
    <cfset QueryString_find=ListDeleteAt(QueryString_find,tem pPos,"&")>
    </cfif>
    <cfquery name="facts" datasource="stuff">
    SELECT DISTINCT ID
    FROM facts
    </cfquery>
    <cfset quoteid=RandRange(1,#facts.recordcount#)>
    <CFQUERY name="quotes" datasource="stuff">
    SELECT DISTINCT ID, Fact
    FROM facts
    WHERE ID = #quoteid#
    </CFQUERY>


    <html>
    <head>
    <title>Inventory Search Results</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css"
    href="../CSS/newstyle_border1.css">
    <link href="../CSS/newstyle.css" rel="stylesheet" type="text/css">
    </head>

    <body>
    <table width="100%" border="0">
    <!--DWLayoutTable-->
    <tr>
    <td height="96" colspan="2">

    <table width="100%">
    <tr>
    <td width="100%" height="88"><div align="right"><img
    src="../images/efi_logo_left.gif" width="200" height="66" align="left"><img
    src="../images/efi_consumer.gif" width="300" height="66"></div><div
    align="right">
    <font size="1" face="Arial, Helvetica, sans-serif"><strong>Random
    Fact:</strong></font> <cfoutput query="quotes">
    <font size="1" face="Arial, Helvetica, sans-serif">#Fact#</font></div>
    </cfoutput>
    </td></table></td>
    <td width="26">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="23" colspan="3" class="top1" bgcolor="#D7DAC2"><p><a
    href="../index.cfm">Home</a> |
    </p></td>

    <td>&nbsp;</td>
    </tr>
    <tr>
    <td width="125px" height="97" valign="top" bgcolor="#D7DAC2" class="nav1">
    <cfinclude template="../includes/include_nav_border.cfm"></td>
    <td colspan="2" valign="top" bgcolor="#FFFFFF" width="100%"><div
    class="content">

    <div align="center"><h3><a href="inventory.cfm">Back to Inventory
    Page</a></h3></div>


    <table border="1" cellpadding="1" cellspacing="1" align="center" width="100%">
    <tr>


    <td><div align="center"><strong>ItemNumber</strong></div></td>
    <td><div align="center"><strong>Item Discription</strong></div></td>
    <td><div align="center"><strong>On Hand</strong></div></td>
    <td><div align="center"><b>On Sales Order</b></div></td>

    </tr>


    <p>Your search found this many records:
    <cfoutput>#find.RecordCount#</cfoutput></p>
    <cfif find.RecordCount GT 0>

    <CFOUTPUT query="find" startRow="#StartRow_find#" maxRows="#MaxRows_find#">
    <!--- Local function for easier coding. --->
    <tr>

    <td class="CenterCell">#sHighLightKeyWords (find.ItemNumb,
    FORM.item)#</td>
    <td class="CenterCell">#sHighLightKeyWords (find.ItemDisc,
    FORM.item)#</td>
    <td><div align="center">#find.TotalQtyOnHand#</div></td>
    <td><div align="center">#find.QtyOnSalesOrder#</div></td>

    </tr>
    </CFOUTPUT>
    </table>
    <cfoutput>
    <table border="0" width="50%" align="center">
    <tr>
    <td width="23%" align="center"><cfif PageNum_find GT 1>
    <a href="#CurrentPage#?PageNum_find=1#QueryString_fin d#">First</a>
    </cfif>
    </td>
    <td width="31%" align="center"><cfif PageNum_find GT 1>
    <a
    href="#CurrentPage#?PageNum_find=#Max(DecrementVal ue(PageNum_find),1)##QueryStri
    ng_find#">Previous</a>
    </cfif>
    </td>
    <td width="23%" align="center"><cfif PageNum_find LT TotalPages_find>
    <a
    href="#CurrentPage#?PageNum_find=#Min(IncrementVal ue(PageNum_find),TotalPages_fi
    nd)##QueryString_find#">Next</a>
    </cfif>
    </td>
    <td width="23%" align="center"><cfif PageNum_find LT TotalPages_find>
    <a
    href="#CurrentPage#?PageNum_find=#TotalPages_find# #QueryString_find#">Last</a>
    </cfif>
    </td>
    </tr>
    </table>
    </cfoutput>

    </cfif>
    <cfif find.RecordCount EQ 0>
    <table width="100%">
    <tr>
    <td><p align="center"><font size="4" face="Arial, Helvetica,
    sans-serif"><strong>Sorry, but we didn't find what you were looking
    for!</strong></font></p></td>
    </tr>
    </table>
    </cfif>

    </div></td>


    </tr>
    <tr>
    <td height="5"></td>
    <td width="587"></td>
    <td></td>
    <td></td>
    </tr>



    </table>
    <table width="100%">
    <tr>
    <td class="footer1" colspan="4" bgcolor="#D7DAC2"><cfinclude
    template="../includes/include_footer.cfm"></td>
    </tr>
    </table>




    </body>
    </html>


    EnergyFed Guest

  5. #4

    Default Re: Need help w/search script

    you've got a cfparam on form.item before the url.item stuff. get rid of that first cfparam on form.item and see what happens.
    jonnycattt Guest

  6. #5

    Default Re: Need help w/search script

    No, that didn't work :( I don't know what to do. It just will not pass that variable along to the next page.
    I am not going to worry about it right now. Thank you for your help.
    EnergyFed Guest

  7. #6

    Default Re: Need help w/search script

    ..
    cpayne624 Guest

  8. #7

    Default Re: Need help w/search script

    what appears in your browser's address bar when you click a back/next link? can you paste the entire url here?
    jonnycattt Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139