not show result details mysql in jquery -


the below code html code:

<input type="search" name="srchtxt" id="srchtxt"/> <div class="resultsearch">     <ul class="ul"></ul> </div> <a href="#" id="srchbtn"></a> 

and below code jquery code:

$("#srchtxt").keyup(function(){     var addresshome = $("#srchtxt").val();     $.post("addressfile",{address:addresshome},function(res){         $(".ul").html(res);     }); }); $(".ul li#item a").each(function(){     $(this).click(function(e){         e.preventdefault();         var index_address,address;         index_address = $(this).parent().index();         alert(index_address);         address = $(this).eq(index_address).attr("value");         $("#srchtxt").attr("value",address);     }); }); $("#srchbtn").click(function(){     alert($("#srchtxt").val()); }); 

and below code php code:

$address = $_post['address'];$querysrch = "select city,state,bolv table city '%".$address."%' or state '%".$address."%' or bolv '%".$address."%'";$ressrch = mysqli_query($cnt,$querysrch);if(mysqli_num_rows($ressrch) > 0){ while($row = mysqli_fetch_assoc($ressrch)){     $addressres = $row['city']."-".$row['state']."-".$row['bolv'];     echo "<li id='item'><a href='#' value='".$addressres."'>".$addressres."</a></>"; }}else{    echo "<li id='item'><a href='#' value='not found'>notfound</a></li>";} 

when result show can't access value li list show value or insert id="srchtxt"

try code:

$results = ''; $address = $_post['address']; $querysrch = "select city,state,bolv table city '%".$address."%' or state '%".$address."%' or bolv '%".$address."%'"; $ressrch = mysqli_query($cnt,$querysrch); if(mysqli_num_rows($ressrch) > 0){     while($row = mysqli_fetch_assoc($ressrch)){         $addressres = $row['city']."-".$row['state']."-".$row['bolv'];         $results .= "<li id='item'><a href='#' value='".$addressres."'>".$addressres."</a></li>";     } } else {      $results .= "<li id='item'><a href='#' value='not found'>notfound</a></li>"; } echo $results; return; 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -