auto complete text box in php and mysql -


i`m trying make auto complete text box in php. here javascript code

<script src="assets/js/jquery-1.10.2.js"></script> <script src="assets/js/jquery-1.3.2.min.js"></script> <script src="assets/js/jquery-ui-1.10.4.custom.min.js"></script> <script type="text/javascript"> jquery(document).ready(function(){ $('#search').autocomplete({ source : 'search-job.php', minlength:2 });  }); </script> 

here html code

<input type="text" id="search" class="form-control input-lg col-xs-4" name="search"> 

here search-job.php

<?php include 'connectdb.php'; if(isset($_request['term'])) exit (); $rs=  mysql_query("select * jobs `title` '%"  . ucfirst($_request['term']). "%' order id asc limit 0,10") or      die(mysql_error()); $data=  array(); while($row=  mysql_fetch_assoc($rs,mysql_assoc)){ $data[]=array( 'label'=>$row['title'], 'value'=>$row['title'] ); } echo json_encode($data); flush(); 

i`m getting correct values in search-job.php. not catching html when run code nothing happened? why that?

this how it`s looks on network tab according not passing values term correctly

the array format passing wrong.

$data[]=array( 'label'=>$row['title'], 'value'=>$row['title'] ); 

should

$data[$row['title']]= >$row['title']; or $data[]= >$row['title']; 

and

replace

source : 'search-job.php', 

with

source: 'search-job.php?term='+document.getelementbyid('search').value, 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -