mysql db result convert as a json array
mysql db result convert as a json array
I am trying to write a auto complete, which the auto complete items load one time when the PHP page loads. With the items that are fetched from mysql DB , i have create a json array like this
$rBnk['BName'], 'value' => $rBnk['BName'], 'otherDetails' => $rBnk['BName'].'||'. $rBnk['BCode'].'||'. $rBnk['ID'] ); array_push($bnkArray, $bnkDet); } ?>
i need this array as like this javascript array
if i call this array like this in my auto complete this is not working
var bankSource = [];
what is this array type.. how to do this.
this is the autocomplete part
$(this).autocomplete({ minLength: 0, source: bankSource, focus: function( event, ui ) { $(this).val( ui.item.label ); return false; }, select: function( event, ui ) { console.log(ui.item.value +' ____ ' + ui.item.otherDetails); $( "#project" ).val( ui.item.label ); $( "#project-id" ).val( ui.item.value ); $( "#project-description" ).html( ui.item.otherDetails ); return false; } }) }
Answer by mapek for mysql db result convert as a json array
Please replace
var bankSource = [];
with
var bankSource = ;
Answer by Rahul Gavande for mysql db result convert as a json array
You should do following :
var bankSource11 = [];
Answer by Niranjan N Raju for mysql db result convert as a json array
change this line like this,
var bankSource = [];
to
var bankSource = "";
Php variable is enclosed with quotes and assigned to js variable.
Answer by sandeepsure for mysql db result convert as a json array
Here is a sample example which i modified accroding to your requirement. Kindly study it and let me know if you have any question.
$rBnk['BName'], 'value' => $rBnk['BName'], 'otherDetails' => $rBnk['BName'].'||'. $rBnk['BCode'].'||'. $rBnk['ID'] ); array_push($bnkArray, $bnkDet); } ?> jQuery UI Autocomplete - Default functionality
Answer by Khoai for mysql db result convert as a json array
Note the single quotes, because it's string:
var bankSource = '';
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment