appending to user's string

Results 1 to 7 of 7

Thread: appending to user's string

  1. #1
    Join Date
    Dec 1969
    Posts
    147

    Default appending to user's string

    hi:)<BR><BR>i have a search function that allows exact search or not exact search. for non exact search, the user had to key in the searching word with %%(clause) enter behind it.<BR><BR>how to i make it more user friendly by not needing the user to key in %% ? i try to append %% to the user string after it is submitted:<BR><BR>&#060;%<BR>company=request.query string("st")<BR>myexactsearch=request.querystring( "exactsearch")<BR>SQLtemp="select * from CUSTOVE1 where COMPANY"<BR>If myexactsearch="on" then<BR> ia=company<BR> SQLtemp=SQLtemp & " =&#039"<BR>Else<BR> ia=company+"%%"<BR> SQLtemp=SQLtemp & " LIKE &#039"<BR>End If<BR>SQLtemp=SQLtemp & ia & "&#039"<BR>&#039response.write SQLtemp<BR>call query2table(SQLtemp)<BR>&#037;&#062;<BR><BR>unfort unately it could not work. can anyone help?<BR><BR>thanks<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    511

    Default RE: appending to user's string

    Chance the ia = company + "%%"<BR><BR>to<BR><BR>ia = company & "%%"<BR><BR>You could have a check box that the user could click to say it they wanted an exact search or not.<BR><BR>hope that helps<BR><BR>Pete

  3. #3
    Ben Jones Guest

    Default RE: appending to user's string

    &#060;%<BR><BR>company = request.querystring("st")<BR>myexactsearch = request.querystring("exactsearch")<BR><BR>sSQL = "SELECT * FROM custove1 WHERE company "<BR><BR>if myexactsearch = "on" then<BR> sSQL = sSQL & " = &#039" & company & "&#039"<BR>else<BR> sSQL = sSQL & " = &#039%" & company & "%&#039"<BR>end if<BR><BR>call query2table(sSQL)<BR><BR>&#037;&#062;

  4. #4
    Join Date
    Dec 1969
    Posts
    147

    Default RE: appending to user's string

    thanks for both of ya, thanks for the script!<BR><BR>i have insert a LIKE to the script:<BR><BR>&#060;%<BR>department=request.query string("sd")<BR>myexactsearch=request.querystring( "exactsearch")<BR>SQLtemp="select * from CUSTOVE1 where DESIGDEPT"<BR>If myexactsearch="on" then<BR><BR> SQLtemp = SQLtemp & " = &#039" & department & "&#039"<BR><BR>Else<BR> <BR> &#039SQLtemp=SQLtemp & department & "LIKE &#039%" & deparment & "%&#039" <BR> SQLtemp = SQLtemp & " LIKE &#039%" & department & "%&#039"<BR> <BR>End If<BR><BR>&#039response.write SQLtemp<BR>call query2table(SQLtemp)<BR>&#037;&#062;<BR><BR>it works but when it search, it display other datas which is not <BR>revelant, for eg when i search for v for the field DESIGDEPT, other records which contain no v were also displayed.<BR><BR>can anyone help again?<BR><BR>thanks a million=)<BR><BR>karen


  5. #5
    Join Date
    Dec 1969
    Posts
    511

    Default RE: appending to user's string

    Not sure about that one. Got any more examples or sample data, can you explain it a bit more, like what exactly you are typing in and whats coming out. <BR><BR>Pete

  6. #6
    Ben Jones Guest

    Default RE: appending to user's string

    RE: it works but when it search, it display other datas which is not revelant, for eg when i search for v for the field DESIGDEPT, other records which contain no v were also displayed.<BR><BR>That&#039s probably a programming error. I would start by cleaning up your naming conventions. If you&#039ve got a field named "department" in ASP, then it makes the script easier to debug if your form field is also called "department". I would also double check the SQL being sent to the server by un-remming the "response.write SQLTEMP" line. I&#039ve never had a search result returned in SQL that didn&#039t properly match the parameters I established in the search.

  7. #7
    Join Date
    Dec 1969
    Posts
    147

    Default RE: appending to user'string

    thanks:)!<BR><BR>i have another question. how do i make it to display null records when the searching term is not found inside the field? so far it had display another set of irrelevant records.<BR><BR>thanks

Posting Permissions

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