Am trying to use the Autocomplete plugin which so far works in Firefox
but doesn't work in IE6 and opera 9.x on Ubuntu Linux. Below is my
code. So sorry if this has been answered before.


-----------------Backend Code--------------------------
<?php
        $name = $_GET['q'];
        if (!isset($name)) return;

    $link = mysql_connect('localhost', 'root', '');
    mysql_select_db('espreadv2', $link) or die("Error connecting to
db");



    // try to sanitize
    if (get_magic_quotes_gpc()) {
          $name = stripslashes($name);
    }

    $sql = sprintf('select stockcode from stock where stockcode like
"%s%%"', mysql_real_escape_string($name));
    $results = mysql_query($sql);




    if (mysql_num_rows($results) == 0) {
        echo "no such stock";
    } else {
        while ($row = mysql_fetch_object($results)) {
           echo $row->stockcode."\n" ;

        }
    }

    mysql_close($link);


?>


--------Html code--------------------------------
<?php include 'stocks.php'; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd";>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>jQuery load example</title>
<style type="text/css" media="screen">
<!--
body { font: 1em "Trebuchet MS", verdana, arial, sans-serif; font-
size: 100%; color: #000; padding: 20px;}
input, textarea { font-family: Arial; font-size: 100%; padding: 3px;
margin-left: 10px; }
#wrapper { width: 600px; margin: 0 auto; }
</style>
<link rel="stylesheet" type="text/css" href="js/main.css" />


<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.autocomplete.js" type="text/javascript"></
script>
<script src="js/jquery.ajaxQueue.js" type='text/javascript'></script>
<script type="text/javascript">
$(document).ready(function () {
$("#search").autocomplete("stocks.php", {
                width: 260,
                selectFirst: false
        });


})
</script>
</head>
<body>
   <form autocomplete="off" >
                <p>
                        <label>Stocks:</label>
                        <input type="text" id="search" name="name"/>

                </p>
</form>
</body>

Reply via email to