Utilizing PHP to extract information from a mySql database and presenting it as JSON data for JavaScript integration. I aim to insert the acquired JSON data into a JavaScript array:
var DataArray = new Array();
$.getJSON("php_src/getData.php?rTable="+myTable, function(data) {
myData = data;
$.each(myData , function(i,jsonData) {
var bid = jsonData.user_id;
$myBidFound = -1;
for( $i=0; $i<DataArray.length; $i++ )
{
if( DataArray[$i][0].user_id == bid )
{
$myBidFound = $i;
break;
}
}
if( $myBidFound == -1 )
{
$myBidFound = bid;
}
DataArray[$myBidFound] = new Array(jsonData);
});
});
Is this the most efficient approach?