jquery - Multiple textbox population with Ajax and PHP -
hello have code has multiple textbox populations based on ajax , php.
so each textbox has populate own data mysql.
its working fine except textboxes using same output when input data differend tables. how can separate them each show there table results database ?
$query , $query2 textboxes.
here code:
<?php $db = new mysqli('localhost', 'root' ,'*', 'records'); if(!$db){ // show error if cannot connect. echo 'error: not connect database.'; } else { // there posted query string? if(isset($_post['querystring'])) { $querystring = $db->real_escape_string($_post['querystring']); // string length greater 0? if(strlen($querystring) >0) { $query = $db->query("select naam_klant overboekingen naam_klant '$querystring%' limit 10"); $query2 = $db->query("select boekingsnummer overboekingen boekingsnummer '$querystring%' limit 10"); if($query) { while ($result = $query ->fetch_object()) { echo '<li onclick="fill(\''.$result->naam_klant.'\');">'.$result->naam_klant.'</li>'; } } if($query2) { while ($result = $query2 ->fetch_object()) { echo '<li onclick="fill(\''.$result->boekingsnummer.'\');">'.$result->boekingsnummer.'</li>'; } } else{ echo 'error: there problem query.'; } } else{ } // there querystring. } else { echo 'there should no direct access script!'; } } ?>
html:
<label>boekingsnummer</label> <input type="text" name="boekingsnummer" size="20" class="inputstring" onkeyup="lookup(this.value);" onblur="fill();" > <div id="suggestionsbox" class="suggestions" style="display: none;"> <div id="suggestionlist" class="autosuggestionslist"> </div> </div> <label>naam klant</label> <input type="text" name="naam_klant" size="20" class="inputstring" onkeyup="lookup(this.value);" onblur="fill();" > <div id="suggestionsbox" class="suggestions" style="display: none;"> <div id="suggestionlist" class="autosuggestionslist"> </div> </div>
Comments
Post a Comment