Results 1 to 10 of 27

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Posts
    120
    Plugin Contributions
    0

    Default Adding LIVE ajax searching to search box

    Hi, i am trying to add live ajax searching to the search box... i have succeeded in doing it without using zens functions. but, then my output on certain character rendering doesnt work. so i would like to use the built in zen functionality since it is displaying these characters correctly in other parts of the site.

    some background...
    i am using scriptaculous / prototype for the js library. this is loaded and functioning. in my search form i added:
    $content .= '<div id="autocomplete_choices" class="autocomplete"></div>
    <script>
    new Ajax.Autocompleter("autocomplete","autocomplete_choices","search/ajaxsearch.php",{paramName: "search"});
    </script>';
    after the input tag.

    i loaded the js files into template/mytemplate/jscript and put references in my header.

    the param above search/ajaxsearch.php calls the query on the database. following is the code: the first set commented is the code that works (but returns weird characters on letters with accents) the second code block doesnt return anything on the query.

    <?php
    /*
    mysql_connect('localhost', 'user', 'password');
    mysql_select_db("mydatabasename");




    if(!isset($_REQUEST["search"])) exit;
    $search=mysql_real_escape_string(trim($_REQUEST["search"]));
    $result = mysql_query("SELECT products_name, products_description.products_id, products.products_id, products_status FROM products_description, products WHERE products_description.products_id = products.products_id AND products_status=1 AND products_name LIKE '%$search%';");
    if(mysql_num_rows($result)) {
    echo "<ul>";
    while($r=mysql_fetch_assoc($result)) {
    $title = $r["products_name"];


    echo "<li>$title</li>";
    }
    echo "</ul>";
    }
    */

    ?>
    //////NEW BLOCK HERE///////
    <?php

    require('includes/application_top.php');

    $content = '';
    if(!isset($_REQUEST["search"])) exit;
    $search=mysql_real_escape_string(trim($_REQUEST["search"]));


    $product_query = mysql_query("SELECT a.products_id, b.products_id, b.products_name
    FROM products a, products_description b where a.products_id = b.products_id order by b.products_name AND products_name LIKE '%$search%';");

    $product_result = $db->Execute($product_query);
    $content .= "<ul>";
    while (!$product_result->EOF) {
    $content .= '<li>'. $product_result->fields['products_name'] . '</li>';
    $product_result->MoveNext();

    };

    $content .= "</ul>";



    ?>
    <?php echo $content; ?>

    any help would be really really appreciated. i have gotten really far on this and i think a lot of people would like this adaptation. oh and this ajaxsearch.php file is in a subfolder search from the root. not sure if that is the issue or not...

    Minnie

  2. #2
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Adding LIVE ajax searching to search box

    Do your tables have prefix?
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  3. #3
    Join Date
    Jun 2005
    Posts
    120
    Plugin Contributions
    0

    Default Re: Adding LIVE ajax searching to search box

    no they dont..

  4. #4
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Adding LIVE ajax searching to search box

    Did you try to catch the returned result and see what is returned?
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  5. #5
    Join Date
    Jun 2005
    Posts
    120
    Plugin Contributions
    0

    Default Re: Adding LIVE ajax searching to search box

    nothing is returned, which is why i think i am not connecting to the database. The query is good. i have tested it in a module sidebox.

  6. #6
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Adding LIVE ajax searching to search box

    Quote Originally Posted by Minnie Mouse View Post
    nothing is returned, which is why i think i am not connecting to the database. The query is good. i have tested it in a module sidebox.
    Pretty weird, did you try to access this file directly? What do you get then? (You can edit the code to put a test string for $search.)
    If you get a blank page, use this https://www.zen-cart.com/tutorials/index.php?article=82
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

 

 

Similar Threads

  1. Search box in Admin not searching in product name?
    By rudyh01 in forum Basic Configuration
    Replies: 6
    Last Post: 13 Dec 2011, 03:47 PM
  2. Adding a Search Box
    By davisz in forum General Questions
    Replies: 10
    Last Post: 2 Mar 2011, 02:16 PM
  3. Search box not searching capitalized product name/model number
    By saitomedia in forum General Questions
    Replies: 2
    Last Post: 10 Feb 2010, 08:01 AM
  4. Ajax Live Search & Category Trees?
    By unixtized in forum General Questions
    Replies: 2
    Last Post: 12 Sep 2009, 12:16 PM
  5. Replies: 0
    Last Post: 22 Feb 2008, 06:12 PM

Posting Permissions

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