Hi guys,
I am trying to populate a table using jQuery $.post
, but I keep getting (an empty string)
when I log the data using firebugs console.log()
, here is the code,
jQuery:
$.each(data, function(i, json){
//get the system names
$.post('get_system_name.php', {product_id:json.product_id}, function(data){
console.log(data);
});
});
PHP:
$product_id = $_POST['product_id'];
mysql_connect("localhost", "user", "1234") or die(mysql_error());
mysql_select_db("eskom_products") or die(mysql_error());
$query = mysql_query("SELECT products FROM products WHERE product_id='".$product_id."'") or die(mysql_error('Please try again'));
$array = mysql_fetch_array($query, true);
echo $array['products'] ;
Initially I do a $.getJSON()
request, and then I loop through all of the entries I get back using $.each
, but as you can see, the name of the system is not in the same table, so I need to do a seperate $.post()
to get the name in the related table, but all I get is an empty string, any ideas?