03
fév

FaceBook Like – jQuery and autosuggest Search Engine

Download It !

 

Je vous présente ici module permettant de mettre en place un moteur de recherche style "FaceBook" avec autocomplétion.

 

Ce module s’appuie sur les librairies de jQuery, ainsi que sur le module d’autocomplétion ‘Bsn Autosuggest".

 

Côté customisation, on peut s’appuyer sur des plugins de recherche qui permettent de catégoriser les résultats de recherche.

 

=> Exemple : http://web2ajax.fr/examples/facebook_searchengine/

 

Have Fun !

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists

119 commentaires

  • Rob Said:

    Very nice! Good work.

  • PanterA Said:

    You rock fuckin’ hard baby

  • mark Said:

    Good work man!

  • cmepthuk Said:

    good work!

  • Facebook » FaceBook Like - jQuery and autosuggest Search Engine Said:

    [...] Blackprof.com â

  • CSSgallery.info » ajax autosuggest or autocomplete Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine [...]

  • sayed Said:

    very good

  • br Said:

    I love it, and will spend some time digest it :)

  • Guiltouf Said:

    Thanks !
    Greatful design for your website and good luck !

  • Raman Basu Said:

    Dynamically add rows with Autosuggest enabled for textboxes using http://ramanbasu.com/tricks/DynamicRow/

  • 37 More Shocking jQuery Plugins Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for design, use jQuery as ajax framework [...]

  • 37个更加出色的jQuery插件 | 帕兰映像 Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- 一个类似于Facebook的搜索引擎,主要的特点就是搜索时的自动提示 使用 [...]

  • 37 plugins para jQuery « Think Free - Linux.Php.Java.ME.Movies Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine, Masked Input Plugin, jQuery Enchant, EasyDrag jQuery Plugin, Simple Effects Plugins y Slide out [...]

  • j Said:

    Thanks for the comments. You’ve got a pretty useful site here so keep it up!

  • 37 More Shocking jQuery Plugins | SEO & Web Design Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest see engine is inspired from facebook for design, ingest jQuery as ajax support [...]

  • 37 More Shocking jQuery Plugins | SEO & Web Design Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest see engine is inspired from facebook for design, ingest jQuery as ajax support [...]

  • skinner_n Said:

    Great work!

  • Juan Martin Said:

    I have download the example but it didnt work. Can you upload another examplo with sql?

  • dotcom Said:

    En fet je quoi avoir trouvé le probleme, je n’ai pas de json sur php4 :)

  • “The Complete Guide” for jQuery Developer- Reblog « Dynamic Disruption Said:

    [...] Autosuggest search engineSuggest form field values the Facebook way. [...]

  • Nicolas Said:

    Félicitations, très joli et efficace!!

    J’aurais besoin d’une petite personnalisation de ce module…
    Pouvez-vous me contacter pour en discuter?

    Salut!

  • Geert Said:

    Hi,

    Thanks for this great plugin. However I’m having some troubles implementing it on my server.

    I managed to get the results from my MySQL DB, however in the process I lost the division between the « country’s and capitals ».

    The division is the grey box in the search results that nicely separates the different type of results.

    Could you point me into the direction of which part of the code handles the seperation?

    Thanx alot!
    Geert

  • 37 More Shocking jQuery Plugins at expertzweb Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for [...]

  • 37 More Shocking jQuery Plugins « Web Design Company in India, Delhi Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for [...]

  • 28 Autocomplete Scripts « The Adventures of Amit Dua Said:

    [...] Facebook like Autocomplete [...]

  • Deepak Said:

    This a very Good Script for the webmasters thanks for this.
    Deepak Oberoi
    http;//www.expertzweb.com

  • Adil Kara Said:

    how do i use this example with mysql?
    Cand u help me?

  • Guiltouf Said:

    Hi,

    To use a mysql request to return results :
    - do your request
    - format the results in json like the page « http://web2ajax.fr/examples/facebook_searchengine/AjaxSearch/_doAjaxSearch.action.php?json=true&limit=8&input=je » I load in ajax

    For example, I use this php class to encode an array in json : http://solarphp.com/class/Solar_Json

    Hoping my answer will help you.

    Bye

  • Mike Bosch Said:

    Is there anyway to « preload » the data without the user having to type anything first. So right when he starts typing, the data is available instantly?

  • Guiltouf Said:

    @Mike : Yes you can and you have two ways :
    1/ You generate a js file with php and load it in your headers

    2/ The other solution is calling a js file after the autocomplete loading with $.get and in the success trigger, you assign the result of the js to a var

    In those two cases, look in the example that is exactly what I do.

    Ciao.

  • Mike Bosch Said:

    I’m not sure I follow. I’m trying to make the request to my php page only one time when the document loads. So I have no need for an « input » parameter either. I understand how to use the $.get and assign the resulting json to a variable, but how do I inject that into the list?

  • Nicolas Said:

    c’est souvent très sympa dev visiter ton bllg ;)

  • Guiltouf Said:

    Merci Nicolas, même si je n’ai pas trop eu le temps de poster en ce moment…

    Mais je vais bientôt me rattraper, ne vous inquietez pas :)

  • Guiltouf Said:

    @Mike :

    I’m sorry but for moment I don’t understand your needs :(
    If you have no need for an input, did you really want an autocomplete plugin ?

    Perhaps you need a combobox rather ?

    But as i said, i’m not sure to imagine what you think about… So tell me more :)

  • adil kara Said:

    Dear friend
    i try u r answer but, i cant do it.
    can u upload any code anywahere?
    I dont want use array, i want filter from just mysql
    Please help me.
    Sory form my bad eng.
    Thank u so much.

    Adil Kara Said:

    how do i use this example with mysql?
    Cand u help me?

    octobre 20th, 2008 at 10:53 Guiltouf Said:

    Hi,

    To use a mysql request to return results :
    - do your request
    - format the results in json like the page “http://web2ajax.fr/examples/facebook_searchengine/AjaxSearch/_doAjaxSearch.action.php?json=true&limit=8&input=je” I load in ajax

    For example, I use this php class to encode an array in json : http://solarphp.com/class/Solar_Json

    Hoping my answer will help you.

    By

  • Most Wanted Ajax Techniques: 50+ Ajax Examples and Tutorials | Noupe Said:

    [...] 16.2 FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Most Wanted Ajax Techniques: 50+ Ajax Examples and Tutorials | SulVision Said:

    [...] 16.2 FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Bluesman75 Said:

    You rox man !!!
    Superb plugin!

  • Ajaxian » Groups of 50+ Ajax Examples Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Most Wanted Ajax Techniques « Program2.0 Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine [...]

  • links for 2008-11-06 « Richard@Home Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine (tags: jquery autosuggest search autocomplete plugin) [...]

  • Most Wanted Ajax Techniques: 50+ Examples and Tutorials | SulVision Said:

    [...] 16.2 FaceBook Like – jQuery and autosuggest Search Engine [...]

  • pligg.com Said:

    FaceBook Like – jQuery and autosuggest Search Engine…

    FaceBook Like – jQuery and autosuggest Search Engine…

  • Most Wanted Ajax Techniques: 50+ Examples and Tutorials - HackSystems Said:

    [...] 16.2 FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 37 More Shocking jQuery Plugins « Web Design Company in India: Posh Web Solutions Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for [...]

  • Interested Developer Said:

    Hi,

    I downloaded the code and uploaded it to my server. The page loads ok, but when I type into the input boxes I get the following javascript error:

    ———————–
    Line: 154
    Char: 2726
    Error: Syntax error
    Code: 0
    URL:
    ———————–

    Do you have any idea what might be causing the error?

    Thanks

  • Guiltouf Said:

    @Interested Developer :

    I’ll just recommend you to use Firefox and his Firebug extension or the excellent Google Chrome to debug your dev.

    IE does this so bad…

    Once you installed Firebug, you’ll see that the error message have more interests :)

    Ciao.

  • Pasha Said:

    great plugin! I have tried a few different ones but this one is the best I could find.

    I just have one issue and was wondering if you were planning to have something like this in your code.

    Basically I want to display all values and not limit the search. And then just display the values in a scrollable div. I have made the css changes to have a fixed height for the div and just have a overflow: auto. But the issue I am facing is that when you scroll through the list with up/down keys it does not scroll the list. So there needs to be something in javascript that tracks the selected item and scrolls the div relatively.

  • jack Said:

    i had the same problem. i used firebug and found the error to be « invalid flag after regular expression »

    i’ve tried to solved it but in void, thinking that the problem must not lie in the codes itself. anyone help~

  • Great New jQuery Plugins! | Design it Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for design, use jQuery as ajax framework [...]

  • adil kara Said:

    Dear friend
    i try u r answer but, i cant do it.
    can u upload any code anywahere?
    I dont want use array, i want filter from just mysql
    Please help me.
    Sory form my bad eng.
    Thank u so much.

    Adil Kara Said:

    how do i use this example with mysql?
    Cand u help me?

    octobre 20th, 2008 at 10:53 Guiltouf Said:

    Hi,

    To use a mysql request to return results :
    - do your request
    - format the results in json like the page “http://web2ajax.fr/examples/facebook_searchengine/AjaxSearch/_doAjaxSearch.action.php?json=true&limit=8&input=je” I load in ajax

    For example, I use this php class to encode an array in json : http://solarphp.com/class/Solar_Json

    Hoping my answer will help you.

    By

  • 50 + Most Useful Ajax Techniques: from Noupe.com « Arunbluebrain’s Flex Said:

    [...] 16.2 FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 100 Top jQuery Plugins | CSS Experiments Said:

    [...] 24) FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for design,  use jQuery as ajax framework and BSN Autosuggest libs. [...]

  • Matt Said:

    Hi,

    This is a great development !

    Now I’m playing with the SQL query to query a Database I’m not able to parse anything when I have an array that should be usable.

    Now you use the same, are you willing to share this information in some more detail with us ?

    Thanks !

    Matt

  • Facebook Like Autocomplete with MySQL Database « Techedout Blog Said:

    [...] to quickly search and select audio and video files in a database. You can download the code from web2ajax and read along to see how I implemented it into my project using a MySQL tables as the [...]

  • Matt Said:

    Hi,

    Your MySQL development is very vague and unclear.

    It does not work as far as I can see. And you should be able to use a simple query with mysql_fetch_array.

    Just simplify, update and be more in detail on your blog, very unclear to lots of people.

    Thanks

    Matt

  • Guiltouf Said:

    @matt :

    1/ I’m totatlly sorry to not offer the prestation you don’t paid…

    2/ I don’t see how my sql development could be vague and unclear, because there is no sql in the example files…

    3/ Please sleep before posting a message, or stop drinking…

    Guiltouf

  • Owen Said:

    Hi this looks like a really great plugin – just what I am after! Thanks for making this available.

    I am new to jQuery and javascript in general, and there’s something I don’t understand…

    Have you done anything special in the js code to make it categorize the results when using multiple plugins? Or is it just the server-side JSON/XML generation that is different to the standard BSN Autosuggest?

    I cannot work it out from your code or your example download, sorry.

    Thanks again,

    Owen

  • Patrick Said:

    Good Work… Thanks!

  • Visual3D Said:

    Salut, je cherchais depuis un bout de temps un moteur de recherche en ajax et là! C’est parfait… Un grand merçi à toi.

    J’ai pu l’intégrer à mon site (en cours de développement) et une question me turlupine : Le script cherche les données (cities & country) sur les deux fichiers php mais je voudrai qu’il cherche via une base de données mySql…

    Débutant en php j’ai essayer d’établir une connexion SQL via les deux fichiers « plugin.capitals.php » et « country » mais rien n’y fait! Je m’y prend comme un pied ^^

    Pourrai-tu m’éclairer ça serait sympa :) ?

    En tous cas j’ai pu visiter ton site, il est super! Bravo et bonne continuation.

    Bonne journée,

  • Guiltouf Said:

    @Owen : to categorize the results, I use a special « info » field called ‘plugin_header’ which is interpreted in JS as a category.

  • Guiltouf Said:

    @Visual3D : pour simplifier un peu les choses, je vais prendre le fichier « plugin.capitals.php’ :

    Ce fichier comme il est dans le .zip se comporte en fait comme une base de donnée, je m’explique : la variable $country_list est en fait la base de donnée complète.
    Si tu regardes Ligne 17, celle qui est commentée, c’est la requête sql que je fais en temps normal , requete que j’ai remplacé pour l’exemple par le tableau $country_list.

    Donc en gros, tu fais ta requete sql qui cherche dans ta table mysql, tu fais une boucle sur les résultats et en gros, avec la classe mysql que j’utilise, ça donnerait ça :


    #@ Detect if loaded by search_engine
    if ( ! SEARCHENGINE_LOADED ) return false;

    #@ Category Name
    $searchCat_name = 'Cities' ;

    #@ Do search
    $sql = 'SELECT * FROM capitals LIKE "%'.$search_engine['options']['input'].'%"
    ORDER BY capital
    LIMIT 0, '.$search_engine['options']['search_limit'] ;
    $db->query($sql) ;

    while ( $val = $db->next_record() ) {
    $results['value'] = utf8_encode($val['capital']). ' ('.utf8_encode($val['code']).')';
    $results['info'] = utf8_encode($val['common_name']) ;
    $search_engine['results'][$searchCat_name][$val[id]] = $results ;
    }

    Est-ce que tu comprends mieux comment utiliser un plugin maintenant ?

  • Visual3D Said:

    Re! Merçi pour ses explications…

    Alors j’ai suivi tes indications mais je n’arrive toujours à faire fonctionner le moteur : et c’est normal puisque je n’arrive pas à établir ma connexion avec ma base de données Sql je pense.

    Je m’y suis pris comme cela :

    ———————————————————————–
    Fichier »configuration.php » :

    ——————————————

    Ma base de donnée : toto
    Table : table_toto
    Champs:
    ID
    TITRE
    DESCRIPTION
    ARTICLES

    —————————————————-
    Et voilà pour le plugin.capitals.php

    // Mon fichier de connexion.php relatif à ma base SQL

    query($sql) ;

    while ( $val = $db->next_record() ) {
    $results['value'] = utf8_encode($val['TITRE']). ‘ (’.utf8_encode($val['ARTICLES']).’);
    $results['info'] = utf8_encode($val['DESCRIPTION']) ;
    $search_engine['results'][$searchCat_name][$val[ID]] = $results ;
    }

    // J’ai remplacer les champs « Capital,code, et id par les champs de ma table

    ?>

    …Aucune connexion en vue : c’est sur il y a des erreurs au niveau de ma connexion SQL!

    Désolé si je t’embête avec ce script. Je l’avoue je commence en php, j’y arrive quelque fois mais ça reste de la bidouille ^^

    Merçi pour ton aide. @++

  • Visual3D Said:

    Re! Merçi pour ses explications…
    Re, oups dsl j’ai oublié d’enlever les « php » , tout ne s’est pas affiché!

    ———————————————————————–
    Fichier »configuration.php » :

    // Paramètres de connexion
    $hostname_toto = « localhost »; // nom serveur
    $database_toto = « toto »; // nom base de données
    $username_toto = « root »; // nom utilisateur
    $password_toto = «  »; // mot de passe

    $sql = mysql_connect($hostname_toto, $username_toto, $password_toto) or trigger_error(mysql_error(),E_USER_ERROR);

    ——————————————

    Ma base de donnée : toto
    Table : table_toto
    Champs:
    ID
    TITRE
    DESCRIPTION
    ARTICLES

    —————————————————-
    Et voilà pour le plugin.capitals.php

    require_once(‘connexion.php’); // Mon fichier de connexion.php relatif à ma base SQL

    #@ Detect if loaded by search_engine
    if ( ! SEARCHENGINE_LOADED ) return false;

    #@ Category Name
    $searchCat_name = ‘Cities’ ; //Je dois laisser Cities ?

    #@ Do search
    mysql_select_db($database_toto, $sql); // j’ai rajouté cette ligne pour établir la connexion est-ce que c’est ok ?

    $sql = ‘SELECT * FROM table_toto LIKE « %’.$search_engine['options']['input'].’%”
    ORDER BY TITRE LIMIT 0, ‘.$search_engine['options']['search_limit'] ;
    $db->query($sql) ;

    while ( $val = $db->next_record() ) {
    $results['value'] = utf8_encode($val['TITRE']). ‘ (’.utf8_encode($val['ARTICLES']).’);
    $results['info'] = utf8_encode($val['DESCRIPTION']) ;
    $search_engine['results'][$searchCat_name][$val[ID]] = $results ;
    }

    // J’ai remplacer les champs « Capital,code, et id par les champs de ma table

  • Guiltouf Said:

    Tiens, je te conseille d’utiliser une classe pour se connecter à mysql, c’est ce que j’utilise dans tous mes projets et c’est beaucoup moins lourd à utilise après.
    Donc tu mets tout ça dans un fichier nommé ‘class.db.php’ :

    < ?php

    class DB {

    var $Host = SQL_HOST; // Hostname of our MySQL server
    var $Database = SQL_BDD; // Logical database name on that server
    var $User = SQL_USER; // Database user
    var $Password = SQL_PASSWORD;// Database user's password

    var $Link_ID = 0; // Result of mysql_connect()
    var $Query_ID = 0; // Result of most recent mysql_query()
    var $Record = array(); // Current mysql_fetch_array()-result
    var $Row; // Current row number
    var $Errno = 0; // Error state of query
    var $Error = "";

    #
    # Create a link id to the MySQL database
    # Allow to call $var = new DB($otherhost,$otherDB,$otheruser,$otherpass);
    # where $other* are connections vars different from
    # $this->Host, etc
    #

    function DB($altHost = "",$altDB = "",$altUser = "",$altPassword = "") {
    if ($altHost == "")
    $altHost = $this->Host;
    if ($altDB == "")
    $altDB = $this->Database;
    if ($altUser == "")
    $altUser = $this->User;
    if ($altPassword == "")
    $altPassword = $this->Password;

    $this->Host = $altHost;
    $this->Database = $altDB;
    $this->User = $altUser;
    $this->Password = $altPassword;
    }

    #@ Class destructor
    function __destruct() {
    $this->close() ;
    foreach ($this as $index => $value) unset($this->$index);
    }

    #
    # Stop the execution of the script
    # in case of error
    # $msg : the message that'll be printed
    #

    function halt($msg, $halt_after = false) {
    echo("
    Database error: $msg
    \n
    ");
    if ( $halt_after ) {
    die("
    @=> Page loading aborted...
    ");
    } else {
    echo("MySQL error: ") ;
    echo("
    $this->Errno ($this->Error)
    ") ;
    }
    }

    #
    # Connect to the MySQL server
    #

    function connect() {
    global $DBType;

    if($this->Link_ID == 0) {
    $this->Link_ID = @mysqli_connect($this->Host,
    $this->User,
    $this->Password);
    if (!$this->Link_ID) {
    $this->halt("Connect to [$this->Host] failed.
    Please verify Host, Login and Password.", $halt_after = true);
    }
    $SelectResult = @mysqli_select_db($this->Link_ID, $this->Database);
    // Set default to UTF8
    $this->query('SET NAMES UTF8;') ;

    if(!$SelectResult) {
    $this->Errno = mysqli_errno($this->Link_ID);
    $this->Error = mysqli_error($this->Link_ID);
    $this->halt("cannot select database ".$this->Database."", $halt_after = true);
    return false ;
    }
    }

    #@ Else return true
    return true ;
    }

    #
    # Send a query to the MySQL server
    # $Query_String = the query
    #

    function query($Query_String) {
    // DEBUG MODE
    $this->debug = false ;

    // DEBUG : Store microtime to log requests
    ( $this->debug ? $time_start = microtime(true) : false ) ;

    $this->connect();
    //_dumpLog($Query_String) ;
    $this->Query_ID = @mysqli_query($this->Link_ID, $Query_String);
    $this->Row = 0;
    $this->Errno = mysqli_errno($this->Link_ID);
    $this->Error = mysqli_error($this->Link_ID);
    if ( $this->Errno == 2006 ) {
    unset($this->Link_ID) ;
    $this->connect();
    $this->Query_ID = @mysqli_query($this->Link_ID, $Query_String);
    $this->Row = 0;
    $this->Errno = mysqli_errno($this->Link_ID);
    $this->Error = mysqli_error($this->Link_ID);
    if (!$this->Query_ID) {
    $this->halt("Invalid SQL: ".$Query_String);
    }
    } else {
    if (!$this->Query_ID) {
    $this->halt("Invalid SQL: ".$Query_String);
    }
    }

    // DEBUG : Store microtime to log requests
    ( $this->debug ? $time_stop = microtime(true) : false ) ;

    // DEBUG WRITE A LOG
    if ( $this->debug ) {
    _dumpLog("sql : $Query_String | exec : " . ( $time_stop - $time_start) . "ms", $error_level=1) ;
    }

    return $this->Query_ID;
    }

    #
    # return the next record of a MySQL query
    # in an array
    #

    function next_record() {
    $this->Record = @mysqli_fetch_array($this->Query_ID, MYSQLI_ASSOC);
    $this->Row += 1;
    $this->Errno = mysqli_errno($this->Link_ID);
    $this->Error = mysqli_error($this->Link_ID);
    $stat = is_array($this->Record);
    if (!$stat) {
    @mysqli_free_result($this->Query_ID);
    $this->Query_ID = 0;
    }
    return $this->Record;
    }

    #
    # return the next record of a MySQL query
    # in an object
    #

    function fetch_assoc() {
    $this->Record = @mysqli_fetch_assoc($this->Query_ID, MYSQLI_ASSOC);
    $this->Row += 1;
    $this->Errno = mysqli_errno($this->Link_ID);
    $this->Error = mysqli_error($this->Link_ID);
    $stat = is_object($this->Record);
    if (!$stat) {
    @mysqli_free_result($this->Query_ID);
    $this->Query_ID = 0;
    }
    return $this->Record;
    }

    #
    # Return the number of rows affected by a query
    # (except insert and delete query)
    #

    function num_rows() {
    return @mysqli_num_rows($this->Query_ID);
    }

    #
    # Return the number of affected rows
    # by a UPDATE, INSERT or DELETE query
    #

    function affected_rows() {
    return @mysqli_affected_rows($this->Link_ID);
    }

    #
    # Return the id of the last inserted element
    #

    function insert_id() {
    return mysqli_insert_id($this->Link_ID);
    }

    #
    # Seeking position
    #

    function data_seek($offset) {
    return mysqli_data_seek($this->Link_ID, $offset);
    }

    #
    # Retourne le resultat d'une requete qui ne veut avoir qu'un seul champ par ligne
    #

    function get_one_data($SQL, $field) {
    $this->query($SQL) ;
    $valSQL = $this->next_record() ;
    return $valSQL[$field] ;
    }

    #
    # Retourne la liste des tables d'une base
    #
    function list_tables($base) {
    $result = $this->query(empty($base) ? 'SHOW TABLES' : "SHOW TABLES FROM `$base`");
    $tables = array();
    while (list($name) = $result->fetch_row()) {
    $id = preg_replace("#^($prefix|$user_prefix)_#", '', $name);
    $tables[$id] = $name;
    }
    $result->free();
    return $tables ;
    }

    #
    # Optimize a table
    # $tbl_name : the name of the table
    #

    function optimize($tbl_name) {
    $this->connect();
    $this->Query_ID = mysqli_query("OPTIMIZE TABLE $tbl_name",$this->Link_ID);
    }

    #
    # Free the memory used by a result
    #

    function clean_results() {
    if($this->Query_ID != 0) {
    mysqli_free_result($this->Query_ID);
    }
    }

    #
    # Close the link to the MySQL database
    #

    function close() {
    if($this->Link_ID != 0) mysqli_close($this->Link_ID);
    }

    #
    # Return list of table's fields
    #
    function get_field_list($tbl_name) {
    $list_fields = mysqli_query("SHOW FIELDS FROM $tbl_name", $this->Link_ID);
    while ($field_name = mysqli_fetch_array($list_fields)) {
    $field_list[] = $field_name[0] ;
    }
    return $field_list ;
    }

    #
    # Fetch all results and return an array with all results
    #
    function fetch_allResults($sql, $no_id = false, $field = false) {
    $this->query($sql) ;
    unset($return_array) ;
    $i = 0 ;
    if ( $this->num_rows() ) {
    while ($val = $this->next_record() ) {
    $return_array[$i++] = $val ;
    }
    @mysqli_free_result($this->Query_ID);
    } else {
    return false;
    }

    // If waiting for only one line in return, use this param
    if ( $no_id ) {
    if ( $field ) {
    return $return_array[0][$field] ;
    } else {
    return $return_array[0] ;
    }
    } else {
    return $return_array ;
    }
    }
    }
    ?>

    Et après, tu mets un fichier de conf que tu appelles avant la classe avec tes paramètres de connexion dedans :

    DEFINE ("SQL_HOST", "127.0.0.1");
    DEFINE ("SQL_BDD", "le_nom_de_ta_base_dev");
    DEFINE ("SQL_USER", "ton_user_mysql");
    DEFINE ("SQL_PASSWORD", "ton_password");

    Tu vas voir, c’est du bonheur en boite après :)

  • visual3d Said:

    Slt, merçi encore une fois de prendre le temps de me répondre :)

    Alors j’ai essayer d’appliquer cette classe, mais le problème c’est que j’ai déja des requêtes sql de faite avec un script de connexion php et divers éléments : il faudrait que je reprenne tout le code pour intégrer correctement cette classe!

    D’autant plus que je suis vraiment débutant en php : c’est pas évident ^^ Mais c’est sur cela doit être beaucoup plus propre.

    J’ai quand même essayer de cette manière qui n’est surement pas la bonne ^^

    ————————————————————–
    Fichier « plugin.capital.php »

    //Ou include?

    query($sql) ;

    while ( $val = $db->next_record() ) {
    $results['value'] = utf8_encode($val['TITRE']). ‘ (’.utf8_encode($val['ARTICLES']).’);
    $results['info'] = utf8_encode($val['DESCRIPTION']) ;
    $search_engine['results'][$searchCat_name][$val[ID]] = $results ;
    }
    ? >

    ————————————–
    Fichier conf.php

    ———————————————
    Fichier db.class.php

    Comme tu me l’a indiqué.

    Je ne sais plus trop ce que je dois faire et je voudrai pas abusé de ton temps, je vais ressayer quand même histoire de me faire la main. Merçi

  • visual3d Said:

    Haa mince encore les « php » dsl !

    ————————————————————–
    Fichier « plugin.capital.php »

    require_once(‘conf.php’);

    //Ou include?

    require_once(‘class.db.php’);

    #@ Detect if loaded by search_engine
    if ( ! SEARCHENGINE_LOADED ) return false;

    #@ Category Name
    $searchCat_name = ‘Cities’ ;

    #@ Do search
    $sql = ‘SELECT * FROM toto LIKE « %’.$search_engine['options']['input'].’%”
    ORDER BY TITRE LIMIT 0, ‘.$search_engine['options']['search_limit'] ;
    $db->query($sql) ;

    while ( $val = $db->next_record() ) {
    $results['value'] = utf8_encode($val['TITRE']). ‘ (’.utf8_encode($val['ARTICLES']).’);
    $results['info'] = utf8_encode($val['DESCRIPTION']) ;
    $search_engine['results'][$searchCat_name][$val[ID]] = $results ;
    }

    ————————————–
    Fichier conf.php

    DEFINE (« SQL_HOST », « localhost »);
    DEFINE (« SQL_BDD », « toto »);
    DEFINE (« SQL_USER », « root »);
    DEFINE (« SQL_PASSWORD », «  »);

    ———————————————
    Fichier db.class.php

    Comme tu me l’a indiqué.

  • masster Said:

    Very cool, it does realy helped me in my work!

  • morgane Said:

    Bonjour,

    j’ai telechargé « autosuggest Search Engine  » et je n’arrive même pas à le faire marcher comme tel ( sans rien modifier ), je pensais que c’était la version de mon easyphp qui était en cause mais même avec easyphp 3 c’est pareil .

    Y’a t-il quelque chose qui m’aurait échappé, j’ai regardé les chemin des pages, j’ai regardé Json sur php info et il est enabled . Si vous avez des pistes je vous en serez reconnaissant .

    Morgane.

  • Guiltouf Said:

    Bonjour Morgane,

    Pour regarder un petit peu ce qui se passe dans la matrice, est-ce que tu as l’extension firebug pour mozilla ?

    Cela va te servir à voir quelles requetes sont envoyées quand tu tapes un caractères dans le champ input et surtout de voir la réponse qui t’es renvoyée.

    Normalement, la réponse doit être au format json. Si ce n’est pas le cas, tu devrais voir des erreurs.

    N’hésite pas à reposter si tu as toujours des soucis.

    Bon courage.

  • morgane Said:

    merci, je vais regarder de ce coté la

  • akantis Said:

    hi.
    I have a problem with the facebook search engine, i adapted it to my mysql db and in my pc (with apache and all the stuff) works fine, but when i update it to the server it doesn’t work more…
    Do you know what can cause the problem?
    The initial message on the text field appears but nothing happens when i wirte some text.
    the strange it’s that it works on my ocal server but not on the website server..
    Can you help me?
    Thanks

  • daniel radcliffe nude Said:

    daniel radcliffe nude http://www.motime.com/profile/danilsad – daniel radcliffe nude Kim Kardashian nude http://ostatic.com/member/mastadon – Kim Kardashian nude Daniel radcliffe nude http://forums.plexapp.com/index.php?showuser=8210 – Daniel radcliffe nude

  • MILEY CYRUS NUDE Said:

    MILEY CYRUS NUDE http://www.linkedin.com/pub/aledsa-deserom/14/1a9/401 – MILEY CYRUS NUDE amanda bynes nude http://www.rizon.net/vbulletin/member.php?u=1792 – amanda bynes nude emma watson nude http://www.uvouch.com/users-mandares – emma watson nude

  • bdsm rape stories Said:

    hm.. funny ))

  • miley cyrus sex tape Said:

    miley cyrus sex tape [url=http://www.codeproject.com/Members/neontarik]miley cyrus sex tape[/url] kim kardashian sex tape [url=http://forums.thedailywtf.com/members/veserolkas.aspx]kim kardashian sex tape[/url]

  • Rihanna nude Said:

    Rihanna nude [url=http://forums.developertutorials.com/members/rihannas.html]Rihanna nude[/url] Rihanna sex tape [url=http://riereta.net/moodle/user/view.php?id=4787&course=1]Rihanna sex tape[/url] MILEY CYRUS SEX [url=http://dotnet.org.za/members/MILEYCYRUS.aspx]MILEY CYRUS SEX[/url]

  • 20+ Ready to Use Auto Completion Scripts  | Dzine Blog Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 20+ Ready to Use Auto Completion Scripts | KolayOnline Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 20 Auto completion Ajax script miễn phí | PCSpace Việt Nam | Tin tức, đánh giá, bình luận và blog về Công nghệ, IT Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 20+ Ready to Use Auto Completion Scripts | Desinine Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Muhammad Abdullah Sheikh » Blog Archive » Ready to Use Auto Completion Scripts for Websites/Web Applications Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 21 Scripts para Autocompletar Listos para Utilizar @ Ciberdix 2.0 :: Blog Creativo!! Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Allan Said:

    Hi Guiltouf,

    I have tried downloading your: FaceBoox style autosuggest with jQuery on the webpage: http://www.web2ajax.fr/examples/facebook_searchengine/

    I cant get the example to work on my local. It comes up with an error

    Message: Syntax error
    Line: 154
    Char: 2726
    Code: 0
    URI: http://localhost/facebook_searchengine/

    I have read all the comments in here, and tried with firefox without any solution of the bugged download you have published hm:/ Can you please help me?

    Regards,
    Allan

  • 20+ Ready to Use Auto Completion Scripts « test Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 20+ Ready to Use Auto Completion Scripts | X Design Blog Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 Useful New jQuery Techniques and Tutorials « Tech7.Net Said:

    [...] web2ajaxFaceBook Like – jQuery and autosuggest Search Engine [...]

  • AMB Album » 50 Useful New jQuery Techniques and Tutorials Said:

    [...] web2ajaxFaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 Useful New jQuery Techniques and Tutorials | huibit05.com Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 Useful New jQuery Techniques and Tutorials « Kata learns to code Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 Useful New jQuery Techniques and Tutorials « William Rodriguez Portfolio Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 plugins para jQuery Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine (demonstração online) Plugin para criar um autosuggest com um design baseado no do Facebook. [...]

  • Script jQuery hữu dụng « “Ngoc Design” Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 Useful New jQuery Techniques and Tutorials « Why Limit Media Said:

    [...] web2ajaxFace­Book Like — jQuery and auto­sug­gest Search Engine [...]

  • 50 Useful jQuery Techniques « Daily Apps|Useful Online Resources Collection Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Advertisers Blog » Blog Archive » 50 Useful New jQuery Techniques and Tutorials Said:

    [...] web2ajaxFaceBook Like – jQuery and autosuggest Search Engine [...]

  • » 50 новых и полезных jQuery-техник и туториалов endo – luxury coding Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 Useful New jQuery Techniques and Tutorials | Search Engine Optimisation Said:

    [...] web2ajaxFaceBook Like – jQuery and autosuggest Search Engine [...]

  • sandrar Said:

    Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

  • Blog do Villela » Blog Archive » 50 plugins para JQuery! Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine (demonstração online) Plugin para criar um autosuggest com um design baseado no do Facebook. [...]

  • 50 jQuery Techniques And Tutorials | oOrch Blog Said:

    [...] web2ajaxFaceBook Like – jQuery and autosuggest Search Engine [...]

  • XanelaWeb – Diseño, web y nuevas tecnologías » Scripts de autocompletado de texto para web Said:

    [...] Facebook like Autocomplete [...]

  • Chitta Said:

    After downloading the code and running in local server i am getting this error Notice: Undefined index: plugin….action.php on line 20\n I got this error in firebug. Also i have noticed this the common error reported by few of the members. You have devloped a great plugin but it will be better if you will fix the common errors it would be a great help.

  • Guiltouf Said:

    Hi Chitta,

    First, I think you have to disable E_NOTICE errors in your php.ini configuration.

    I use something like this in my configuration :
    error_reporting = E_ALL & ~E_NOTICE

    It’s normal if you use all-in-one WAMP like EasyPhp.

    Try this and if you have always the problem, can you log me the full error ( full path of file ).

    Have fun !

  • Best jquery plugins examples,Jquery-css gallery, css scripts showcase ,php scripts,ajax scripts,CMS Drupal,CMS Joomla,CMS WordPress:W3CGallery.com Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for design, [...]

  • Best Ajax examples and technique,Php/Mysql/Ajax Hacks-css gallery, css scripts showcase ,php scripts,ajax scripts,CMS Drupal,CMS Joomla,CMS WordPress:W3CGallery.com Said:

    [...] [...]

  • 100 Ajax And JavaScript Techniques Said:

    [...] jQuery And Autosuggest Search Engine FaceBook Like – jQuery and autosuggest Search Engine. Features autosuggest and ajax support, [...]

  • CoffeeIT.Net » Blog Archive » 20+ Ready to Use Auto Completion Scripts Said:

    [...] 13.) FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Jackson Arruda Diniz Said:

    Dear Friend,

    I’m not getting to donwload of file.

    I’m redirecting to another page without nothing.

    Where is file to download?

    Thanks,

    Jackson A. Diniz (BH/MG/Brazil)
    jacksonanalista@gmail.com

  • Guiltouf Said:

    Hi,

    The download works for me, can you retry from the article’s link ?

    Bye.

  • En Popüler Ajax Eklentileri | FaydalıWeb | Internetin Faydalı Yüzü Said:

    [...] 16.2 FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 50 Useful New jQuery Techniques and Tutorials « Gacik Design Blog Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • Kitefr Said:

    Salut !

    Merci pour ce magnifique plugin mais j’aurai besoin d’un peu d’aide pour le faire marcher avec mysql.

    j’utilise :

    #@ Detect if loaded by search_engine
    if ( ! SEARCHENGINE_LOADED ) return false;

    #@ Category Name
    $searchCat_name = ‘Teams’ ;

    #@ Do search
    $sql = ‘SELECT * FROM teams LIKE « %’.$search_engine['options']['input'].’% »
    ORDER BY name
    LIMIT 0, ‘.$search_engine['options']['search_limit']. »;

    $db = mysql_query($sql);

    #@ Transform txt in array

    while ( $val = mysql_fetch_array($db) ) {
    $results['value'] = utf8_encode($val['name']). ‘ (’.utf8_encode($val['initial']).’);
    $results['info'] = utf8_encode($val['type']) ;
    $search_engine['results'][$searchCat_name][$val['id']] = $results ;
    }

    Mais firebug me met :

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\wamp\www\AjaxSearch\plugin.teams.php on line 27
    {« results »: []}

    Comment je pourrai le résoudre ? :/

    Merci d’avance pour l’aide ^^

  • 50 Useful New jQuery Techniques and Tutorials | Theme Center Said:

    [...] web2ajax FaceBook Like – jQuery and autosuggest Search Engine [...]

  • 20 Excellent Facebook Scripts and Resources - Noupe Said:

    [...] Download this Facebook-inspired auto-suggest search feature here. [...]

  • 20 Excellent Facebook Scripts and Resources | SeanBurdick Said:

    [...] Download this Facebook-inspired auto-suggest search feature here. [...]

  • Excelentes Scripts y recursos de Facebook Said:

    [...] Descargue aquí esta característica de búsqueda por sugerencias automáticas inspirada en Facebook. [...]

  • 37 More Shocking jQuery Plugins « PSD to HTML , Slicing PSD to HTML Said:

    [...] FaceBook Like – jQuery and autosuggest Search Engine- This autosuggest search engine is inspired from facebook for design, use jQuery as ajax framework [...]

  • 5 Awesome Facebook Scripts and Resources Using Jquery | denbagus blog Said:

    [...] 2. Auto-Suggest with Jquery [...]

LEAVE A COMMENT

Comments RSS Feed   TrackBack URL