I have done something like this;

        <script>
            $(document).ready(function(){
                $("#example").autocomplete(
                "test.php"
            ).result(function(a,data,c) {
                    // variable "data" has the value the user selected
                    $("example").html(data);
                });
            });
        </script>

and also something like this;

        <script>
            $(document).ready(function(){
                $("#example").autocomplete(
                "test.php"
            ).result(function(a,data,c) {
                    // variable "data" has the value the user selected
                    data = $("example").text;
                });
            });
        </script>

But still donot see the suggestion for autocomplete from the php, is
anything i am not considering? please help i am really a begininer in this.

my php now looks like this:

<?php
$q=$_GET["q"];

$con = mysql_connect('host', 'user', 'password');
if (!$con)
{die('Could not connect: ' . mysql_error());}

mysql_select_db("tvoc", $con);
$result = mysql_query("SELECT company_name FROM operator WHERE company_name
= '$q'");
if (!$result) {
    echo 'Did not get matching result: ' . mysql_error();
    exit;
}else{
    $row = mysql_fetch_row($result);
    echo $row[10];
}
?>



On Wed, Mar 11, 2009 at 3:36 PM, Joseph Le Brech <jlebr...@hotmail.com>wrote:

>  you are assigning the html here to what's in data.
>
> to access i think is data = $("example").text;
>
> try this but breakpoint it in firebug, because in not using firefox right
> now.
>
> ------------------------------
> Date: Wed, 11 Mar 2009 15:18:10 +0000
> Subject: [jQuery] Re: AutoComplete
> From: brightdad...@googlemail.com
>
> To: jquery-en@googlegroups.com
>
> Do i access "data" like this;
>
>  $("example").html(data);
>
>
>
>
>
> On Wed, Mar 11, 2009 at 3:11 PM, Joseph Le Brech <jlebr...@hotmail.com>wrote:
>
> you should be sanitising your sql aswell.
>
> > Date: Wed, 11 Mar 2009 08:00:23 -0700
> > Subject: [jQuery] Re: AutoComplete
> > From: morni...@gmail.com
> > To: jquery-en@googlegroups.com
>
> >
> >
> > What is the purpose of the ".get()" ?
> >
> > The autocomplete plugin already has the ajax call all wired into it,
> > there's no need to do that on your own
> >
> > $(document).ready(function(){
> > $("#example").autocomplete(
> > "test.php"
> > ).result(function(a,data,c) {
> > // variable "data" has the value the user selected
> > });
> > });
> >
> >
> >
> > On Mar 11, 10:45 am, Bright Dadson <brightdad...@googlemail.com>
> > wrote:
> > > Hi Experts,
> > >
> > > I am trying to use jQuery get function to develop an autocomplete which
> will
> > > display suggestion as soon as users starts typing like this;
> > >
> > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > > "http://www.w3.org/TR/html4/loose.dtd";>
> > > <html>
> > >     <head>
> > >         <script src="http://code.jquery.com/jquery-latest.js
> "></script>
> > >         <link rel="stylesheet" href="
> http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css";
> > > type="text/css" />
> > >         <link rel="stylesheet" href="
> http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomp...";
> > > type="text/css" />
> > >         <script type="text/javascript" src="
> http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgif...
> > > "></script>
> > >         <script type="text/javascript" src="
> http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dime...
> > > "></script>
> > >         <script type="text/javascript" src="
> http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomp...
> > > "></script>
> > >         <script>
> > >             $(document).ready(function(){
> > >                 var result = $.get("test.php", { data:
> > > "q"+$("#example").attr('value') },
> > >                 function(data){
> > >                     $("#example").html(data);
> > >                 });
> > >
> > >                 $("#example").autocomplete(result);
> > >             });
> > >         </script>
> > >
> > >     </head>
> > >     <body>
> > >         Company name: <input id="example" />
> > >     </body>
> > > </html>
> > >
> > > and my backend php script looks like this;
> > >
> > > <?php
> > >      $q=$_GET["q"];
> > >       $con = mysql_connect('host', 'user', 'password');
> > >       if (!$con)
> > >        {
> > >           die('Could not connect: ' . mysql_error());
> > >       }
> > >
> > >       mysql_select_db("database", $con);
> > >
> > >        $sql="SELECT company_name FROM company WHERE company_name =
> > > '".$q."'";
> > >
> > >      $result = mysql_query($sql);
> > >
> > >          while($row = mysql_fetch_array($result))
> > >         {
> > >             echo $row['company_name'];
> > >           }
> > >
> > > mysql_close($con);
> > > ?>
> > >
> > > Unfurtunately tthis donot work as required - i donot see any
> suggestion. Do
> > > anyone know what i am doing wrong here?
> > >
> > > Pls help.
>
>  ------------------------------
> Windows Live Hotmail just got better. Find out 
> more!<http://clk.atdmt.com/UKM/go/134665311/direct/01/>
>
>
>
> ------------------------------
> Windows Live Hotmail just got better. Find out 
> more!<http://clk.atdmt.com/UKM/go/134665311/direct/01/>
>

Reply via email to