Creating a Better Search Form

Hi,
I'm trying to figure out how to create a dynamic search form
using Coldfusion 8.
Right now if I enter multiple words in my search field the
results omit certain records. For example, if I put "toy blue" in
the search field it will return results that only have "TOY BLUE"
together and omits any records that only have "TOY" or only have
"Blue" in the column being searched.
Is there a way to add the following abilities to my basic
search code located at the bottom of my post:
- Search multiple words that are entered in the criteria
input field.
- The words can be separated by commas, spaces, or the word
"and".
- Have it so you can search multiple word phrases by using
quotes.
<!--- Search Form--->
<form name="myForm" method="post"
action="results.cfm">
<p>
<input name="criteria" type="text" id="criteria">
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<!--- Results Page --->
<cfquery name="qSearch" datasource="myDatabase"
dbtype="ODBC">
SELECT itemID, itemName
FROM myTable
WHERE 1 = 1
<cfif IsDefined("form.criteria") AND
Len(Trim(form.criteria))>
and (itemName LIKE '%#form.criteria#%' or itemDescription
LIKE '%#form.criteria#%')
</cfif>
</cfquery>
<p><b>Results:</b></p>
<cfoutput query="qSearch">
<p>#itemid# - #itemName#</p>
</cfoutput>
<!--------->
Any help would be greatly appreciated.
Thanks
-C

This is the relevent sql
and (itemName LIKE '%#form.criteria#%' or itemDescription
LIKE '%#form.criteria#%')
substituting the variable, it looks like this
and (itemName LIKE '%TOY BLUE%' or itemDescription LIKE '%TOY
BLUE%')
You have to treat form.criteria as a list, and loop through
it.

Similar Messages

  • HOW TO CREATE A KEYWORD SEARCH FORM

    Hi, I'm creating a image gallery and I'm about 90% complete. One of my  final objectives is to create a keyword search for my image gallery. I  have 4 fields in my DB, (id,image,description,keywords) I want to be  able to enter keywords into the text field  and the images with there  descriptions show up. I already have the  keywords in my mysql, I already know how to use mysql, I just need to learn how to add a search form that pulls keywords from my mysql. THIS DOES NOT REQUIRE ANY CODE so please do not respond with code. I just need a step by step on what type of form to insert, (dynamic text field or text field) what paramaters to pass etc. NO CODE, this whole thing can be done in design veiw.
    For this project I'm using Dreamweaver Cs5, I'm not really an  experienced coder I rely heavily on dreamweaver for my code, I just make  minor tweaks. So if anyone has an answer to my problem please break  down and simplify your answer I'm still a beginner. Thanks in advance.
    ps
    If anyone knows of any other video tutorials of this process please inform me, it would be greatly appreciated, thank you.(not php acedemies)

    This is helpfull but I'm still running in to some problems. I believe everything on my search page is correct, I think it's my results page thats giving me issues.  When I view my search page in firefox and type in a keyword in the text field, when the results page loads all I get is the field names of DB table (id,layouts,desription,key_words) instead of the actual data...??
    On my search page in the action box I have my results page "search_results.php". In the method box I have "GET".  On my "search_ruselts.php" page I created a recordset, selected all columns, and filtered "key_words". (im not sure if I filtered correctly) I placed this in a dynamic table. Where did I go wrong?
    this is my code if it helps any
    search page:
    <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <form id="form1" name="form1" method="get" action="search_results.php">
      <label for="textfield"></label>
      <input type="text" name="textfield" id="textfield" />
      <input type="submit" name="button" id="button" value="Submit" />
    </form>
    </body>
    </html>
    results page:
    <?php require_once('Connections/test_db.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $maxRows_Recordset1 = 10;
    $pageNum_Recordset1 = 0;
    if (isset($_GET['pageNum_Recordset1'])) {
      $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
    $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
    $colname_Recordset1 = "-1";
    if (isset($_GET['key_words'])) {
      $colname_Recordset1 = $_GET['key_words'];
    mysql_select_db($database_test_db, $test_db);
    $query_Recordset1 = sprintf("SELECT * FROM images2 WHERE key_words = %s ORDER BY id DESC", GetSQLValueString($colname_Recordset1, "text"));
    $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
    $Recordset1 = mysql_query($query_limit_Recordset1, $test_db) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    if (isset($_GET['totalRows_Recordset1'])) {
      $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
    } else {
      $all_Recordset1 = mysql_query($query_Recordset1);
      $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
    $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
    $colname_Recordset2 = "-1";
    if (isset($_GET['id'])) {
      $colname_Recordset2 = $_GET['id'];
    mysql_select_db($database_test_db, $test_db);
    $query_Recordset2 = sprintf("SELECT * FROM images2 WHERE id = %s ORDER BY id DESC", GetSQLValueString($colname_Recordset2, "int"));
    $Recordset2 = mysql_query($query_Recordset2, $test_db) or die(mysql_error());
    $row_Recordset2 = mysql_fetch_assoc($Recordset2);
    $totalRows_Recordset2 = mysql_num_rows($Recordset2);
    ?>
    <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <table cellpadding="4" cellspacing="4">
      <tr>
        <td>id</td>
        <td>Layouts</td>
        <td>Descriptions</td>
        <td>key_words</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><?php echo $row_Recordset1['id']; ?></td>
          <td><?php echo $row_Recordset1['Layouts']; ?></td>
          <td><?php echo $row_Recordset1['Descriptions']; ?></td>
          <td><?php echo $row_Recordset1['key_words']; ?></td>
        </tr>
        <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </table>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    mysql_free_result($Recordset2);
    ?>

  • How to create Pro grammatically Search Form ?

    Version 11.1.1.3.0
    HI i have a requirement where i cant use the search panel/Af:guery panel or View criteria to create the Search form,
    I want simple search on 3 fields and result shld dispaly in table.
    How can i do that??
    Thanks for help

    Two things:
    1. I don't know why you need to have the bean populate the list box -- is it based on other values in the form, requiring a runtime filter? "data" belongs in databases.
    If so, I would recommend looking up Cascading List boxes (Shay has a youtube channel with that) and I have a video on that, too.
    Secondly, you can have list box on the form that will show the "readable" value to the user that they can select. I have a video on that -- possibly the first video I mentioned, but this one may help too.
    http://www.youtube.com/watch?v=ytpLTC5HdvA&feature=plcp
    2. To create a view criteria programatically:
    In the application module, go to the java tab and create an appmoduleimple class. Create a method that manipulates the view criteria and executes the view object. Then expose that on the application module. On the data control, drag and drop the method onto your form. Choose parameter form.
    A form should be created that has the input and button.
    3. On the data control, click on the method and under it, select parameter. drag that onto the form. Select listbox when it asks what kind of control you want to create. Then it will display the listbox gui to connect the database table. This will create a listbox on the form that users can then select. You can manipulate the view object (also using view critieria) behind the listbox to filter data based on some value on the form.
    I am writing from memory here, so I might have skipped a step.
    This may help also: Re: How to filter the list of data
    Edited by: Stuart Fleming on Sep 17, 2012 12:04 PM

  • How can i create my own search form/A user defined search form

    Hello All,
    I have a simple table name employee with two fields, they are Emp_id and Name having 10 recrods.
    I have a form with a text box and a button labled Search.
    I want to search the employee in my employee table. I write the Emp_id in the text box field if the entry (Emp_id) does not exist in the employee table having 10 records then i want a message appear "There is no such employee Code "0001" try again.
    On the other hand if i found some employee in my employee table then it will open the employee form and go to the specified record and show me that record.
    How can i accomplish this task in Oracle Form 6i?
    If anybody help me in this regard i am thankfull to you..
    Please write all necessary code as well.
    Thanks in advance.

    try this one here is :vemp is textitem ,i hope you know how to create button and buttonn's trigger to embed this code
    DECLARE
      cnt           NUMBER := 0;
      RECORD_NUMBER NUMBER;
      VCNT          VARCHAR2(20);
    BEGIN
    GO_ITEM('EMP.empno');
    FIRST_RECORD;
              BEGIN
                   RECORD_NUMBER:=:SYSTEM.CURSOR_RECORD;
                   LOOP
                     IF :EMP.empno = :vemp THEN
                       cnt := cnt + 1;
                       RECORD_NUMBER:=:SYSTEM.CURSOR_RECORD;
                     END IF;
                     EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE' OR cnt > 0;
                     NEXT_RECORD;
                   END LOOP INNER;
                   IF cnt=0 THEN
                           message('No record found..');
                   END IF; 
                   GO_RECORD(RECORD_NUMBER);
              END;
    NEXT_ITEM;
    END;Khurram

  • How To create ADF Search form in JDeveloper 11g 11.1.1.0.1

    Hi,
    I am using JDeveloper 11g 11.1.1.0.1 , in which i tried creating an ADF search form that has Find and Execute Buttons.
    I created the same ADF search form using JDeveloper 11g TP3 and TP4 wherein it works fine but not in JDeveloper 11g 11.1.1.0.1.
    Scenario....
    I dragged a read only view object on to the jspx page as ADF Search Form and dragged the same as Read only table.
    After doing this if i run the application the search functionality does not happen .
    ( I click on the find button and enter the condition and then click on the execute button. records does not get filtered based on that condition specified.)
    But when the same steps is done in 11g TP3 and TP4 the search functionalty works fine.
    Can someone suggest me what is the issue.
    Is this a bug in the new release.
    regards
    vinitha

    reply is in this id
    ADF Searchform with find and execute buttons in JDev 11.1.1.0.1 studio edi.

  • How to create search form in jsf telnet with auto submit?

    I am trying to create a simple search form on a jsf telnet page
    with jdeveloper 10.1.3 and and j2se version 1.4.2.
    The problem I am having is the example search form I have seen
    uses an execute command button, which I can't use on the telnet page.
    I would like to query the results upon entering the criteria, without the
    user pressing a button. This is because the page will used with a barcode
    scanner. I am attempting to use a valueChange listener on the input field, but
    I am unsure if this is the right approach. Any feedback is appreciated.
    Thanks

    In my application whenever I change a value or want to follow a commandLink, my page just refreshes and I end up with the old values. I have not been able to navigate in my application. I am using the arrows or tab to navigate in my page and press enter to submit.
    I have set the STATE_SAVING_METHOD to server, but this is not helping.
    I have a deadline that is closing in on me, can anyone hint me in the right direction?

  • Problems with custom search form in adf

    Hi,
    I am using JDeveloper 11.1.2.4. please can you help with this issue?
    I've created a custom search form with the help from this link.
    Jdeveloper,Oracle ADF &amp;amp; Java: Implementing custom search form in ADF programmatically (Without using af:query)
    I've created two bind variables SkuBind & ImperfectBind and a View Criteria.
    My problem is when I press Search button, it does not filter based on values of the bind variables in the View Criteria.
    I rightly get bind variable values in the System output though
    Skubind = 1000
    Imperfectbind = N
    but there is no where clause
    where clause = null
    public void SearchOddShoes(ActionEvent actionEvent) {
    AppModuleImpl am = (AppModuleImpl)resolvElDC("AppModuleDataControl");
    ViewObject oddShoeVo = am.getRtnOddShoesVO1();
    oddShoeVo.setNamedWhereClauseParam("SkuBind", skuPgBind.getValue());
    oddShoeVo.setNamedWhereClauseParam("ImperfectBind", imperfectPgBind.getValue());
    System.out.print("Named Skubind = " + oddShoeVo.getNamedWhereClauseParam("SkuBind") +"\n");
    System.out.print("Named Imperfectbind = " + oddShoeVo.getNamedWhereClauseParam("ImperfectBind") +"\n");
    System.out.print("where clause = " + oddShoeVo.getWhereClause()+"\n");
    System.out.print("where clause params= " + oddShoeVo.getWhereClauseParams()+"\n");
    System.out.print("Sql is " + oddShoeVo.getQuery()+"\n");
    oddShoeVo.executeQuery();
    public Object resolvElDC(String data) {
               FacesContext fc = FacesContext.getCurrentInstance();
               Application app = fc.getApplication();
               ExpressionFactory elFactory = app.getExpressionFactory();
               ELContext elContext = fc.getELContext();
               ValueExpression valueExp =
                       elFactory.createValueExpression(elContext, "#{data." + data + ".dataProvider}", Object.class);
               return valueExp.getValue(elContext);
    thanks

    Not clear what part of the code doesn't work. Assuming that you did check that the code you wrote executed
    the problem may be the following.
    You need to add partial trigger on the destination component.
    Add ...
    oddShoeVo.executeQuery();
    AdfFacesContext.getCurrentInstance().addPartialTarget(HERE_THE_BIND_NAME_OF_YOUR_TABLE);
    Also I don't see that you acctually use View Criteria. There are specific way to apply View Criteria programatically and I don't see that you use it.
    The simpliest way is just to change the VO query to embed bind variables into the query
    E.G.
    select 1
    from dual
    where some_column= :P_PARAM1

  • How to make a search form with required items?

    Hi
    I am using JDeveloper 11.1.1.2 and JHeadstart 11.1.1.2.29
    I want to make a Search-form for Searching Employees. I want to search for Last Name OR First Name OR Maximum Salary OR ( Combination ManagerID and DepartmentID). One of these is required.
    On the view object for Employees, I defined a view criteria for the search.
    In JHeadstart, I disable Quick Search and set Advanced Search to model-samePage and Advanced Search View Criteria to the view criteria I just defined.
    But now, I can also personalize the Advanced Search. How can I disable this?
    And is this the right way to create such a Search-form or do you have other suggestions?
    Regards,

    The model-based search is standard ADF functionality.
    Jheadstart simply generate the search component on the page. There are a lot of addiitonal properties on af:query that you can set that we do not expose through the Jheadstart application definition editor.
    You can create a custom template to set those additional properties.
    See the af:query tag doc for more info:
    http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e12419/tagdoc/af_query.html
    Steven Davelaar,
    Jheadstart Team.

  • Managing Blank Fields in Search Form

    I am trying to create an advanced search form to filter a recordset of events, so that I can search through these events based on parameters such as category, time, date, place, etc. Right now, because I'm new at this, I have been trying to create a filter with only two parameters, category and price. 'Category' is the first field in the form and 'price' is the second field in the form, followed by fields for time and location. When I search by category, the search works fine. When I search by category and price, only the category parameter works, and it doesn't filter by price. When I search only by price, the recordset comes up as blank. Does this have something to do with fields in the form being left empty or do empty fields have no effect on the search. When I test my query statement on my SQL query browser, it works fine, so I don't think that's the problem. Any help would be appreciated.

    Not an ADDT-specific question so I never responded. However the OP re-posted here in the Dreamweaver Application Development forum which produced a very interesting thread.

  • Custom search form and custom results

    Hi, everyone!
    My problem is that I have to search for custom items with custom fields (attributes). So I have to create my own search form with necessary fields. Than the solution may be to call the portal30.wwsbr_search_api.submit_search procedure, but it renders it's own HTML result with advanced search form. That doesn't suit me. Searching for alternative API, I found portal30.wwv_searchdb.search function. I tried to use it, but in any case it fails with exception and error message "ORA-01403: no data found". From the previous messages I've discovered that there is custom search portlet in 9.0.2. But is it possible to solve my problem without these new features?
    Thank you for your answers ;)
    yk
    P.S. Sorry for my English...

    Yuriy,
    I'm sorry but the portal30.wwv_searchdb.search api is not one of the public apis. There is no simple out of the box way to address your issue with release 1 of Oracle9iAS Portal (you'll have to wait for release 2 for that), but you could do some post processing of the HTML that gets returned from the search results screen and present that to your users. While it would take a little work it would probably give you the functionality you desire.
    You would create a custom search screen, and have the submission call our api with the users values. Then process the results of that call (an HTML page) inside a procedure to finally present your own view of the data.
    Good luck,
    Rich

  • Creating a search form based on a table.

    Hello,
    I'm currently trying to create a search form which performs a searchquery in values stored in a table in my database.
    The table is filled peoples names,lastnames ,telephonenumbers and departments.
    I can use the sample application to make a form based on the tableview but this returns a search textfield for every column in the table. I just want 1 searchfield/textfield to search on ALL columns at the same time and display the other fields as labels when returning the queryresults.
    I tried searching the forums for an explanation on how to build said form and I checked Metalink but I have yet to find one. Anyone out there willing to help me out?
    thanks in advance,
    Melvin K.

    Why not use an instr with your data in a bind variable in your where clause for the select?? Page 1 sets an item called P2_Parameter with your value string slightly modified ('12345','345632','645534534','3434344')
    Select a,b,c,d,e from some_table where INSTR(TO_CHAR(Lookup_column,'099999999'),:P2_Parameter)
    Maybe that will work? Its off the top of my head, but should get you what you want.. (But to agree with one of the other posters, it is a BAD Design..) I would try like an interactive report to allow them to enter in acct #'s or whatever these are and let them access the rows that way..
    Thank you,
    Tony Miller
    Webster, TX

  • How to create a search form? - Jdev TP4 11.1.1.0.0

    Hi,
    I am using Jdev TP4 11.1.1.0.0.
    I have a af:table which is based on a view. I want to have a search form on top of this af:table to query based on the selection in the search form. I have 15 columns in the view. When I drag and drop the "All queriable attributes" from the named criteria I get all these columns in the search form. I need only 3 of the columns in the search form and the af:table should query based on the selection. How can I achieve this? Any help. Thanks in advance.

    You can create a new named query with only these three columns in the where clause and use that.
    Or you can drag the VO as a search form and remove the columns you don't need.

  • Hi I want to create a search form with drop down search criteria. This form should then search on the same site and display the search results. Is there HTML available for this? Or an oline site that I can use to build this form? I created a form in Jotfo

    Hi I want to create a search form with drop down search criteria. This form should then search on the same site and display the search results. Is there HTML available for this? Or an oline site that I can use to build this form? I created a form in Jotform.com, but this form doesn't search the site, instead it sends me an e-mail. Do you have a solution for me? Thanks.

    Hi I want to create a search form with drop down search criteria. This form should then search on the same site and display the search results. Is there HTML available for this? Or an oline site that I can use to build this form? I created a form in Jotform.com, but this form doesn't search the site, instead it sends me an e-mail. Do you have a solution for me? Thanks.

  • Creating a Search form for Captivate courses

    I've been asked to create a search form for our online courses. We do not use the TOC in our courses so the Find field in the TOC is not an option. Here are the ideas I've had so far:
    a Javascript-powered form search
    a search form widget
    a Google search embedded into the surrounding HTML page (But I don't think that Google can "see" text inside the Captivate SWF object...)
    Right now, we are using Captivate 5.5, but do plan to move to Captivate 6.0 fairly soon. I'm grateful for any ideas.
    Thanks!
    Peter

    You're hitting a bug. See ADF Faces Classical Search Form works only with Entity base VO  in JDev 11? for a workaround suggestion.

  • Firefox sync creates duplicate search/form history results

    I have Firefox synced on 3 PCs and a laptop. Some of the sites I visit, sync creates multiple duplicates in form/search boxes. Two that I know of for sure are outlook/hotmail (the box you enter your e-mail address) and my bank website (where I enter my account name). For example, I would see 2 or 3 options to select the same e-mail address in the dropdown history box. If I go to delete all but one of them, it disappears completely the next time so I have zero options.
    This also only happens on some of my computers. Some of them only have one option (which is how it should be).
    Minor issue, but it's kind of bothersome.

    I don't use any sync add ons. The add ons I use are flash video downloader and custom new tab.
    The duplicates are only on my 'other' devices, not my main device (the one I use the most and the one I created my sync account on). I'll have to wait until I get time to go on my other devices to take a screenshot. For now, this is what I mean. Here is the outlook/hotmail sign in page:
    http://www.icts.canterbury.ac.nz/graphics/outlook.com%20login%20screen.JPG
    When I press the down arrow in the account name box, I see 2-3 entries of the same e-mail address. Again, on my main PC, I would only see one entry of my e-mail address (like I should). This also happens on my bank website.
    When I try to delete the duplicates and only keep one entry, the next time I visit the page, they're all gone. So it seems like there's some bug in the search/form history sync.

Maybe you are looking for

  • Conditional build tags applied to topic but it still displays in my TOC?

    I have applied topic level conditional build tags to topics. The corresponding books are still being displayed in my TOC. I checked the 4 topics and the condition is applied at the topic level. What am I missing here?

  • Why Apple will not open the shop in Russia?

    Why Apple will not open the Apple Store in Russia?

  • TS1541 "Mac OS Update Combined" can't be saved

    Hey all, was having issues with my hard drive so I backed up files via TIME MACHINE then erased and reinstalled OS 10.5 then asked it to transfer back my files using TIME MACHINE. For some odd reason, it transferred my files, but left me with 10.5.6

  • Mp4 win to mac

    I have all my files on my windows based computer and I am thinking about switching over to a mac. Will all my mp4 files play on the mac if I copy them over? I heard there is some kind of tag each system throws on the file. Any help would be great.

  • Where did Phonegap Build panel go?

    Hello, I just installed the latest Dreamweaver CC and noticed the Phonegap Build option is completely missing from the Site Menu Where did it go? Thanks, John