I have a call to this php script (only part in question displayed)
if (mysql_num_rows($pquery) == 1) {
$result = mysql_fetch_assoc($pquery);
$query_ht = mysql_query("SELECT * FROM coupon WHERE pid='$result[id]'");
$ht_result = mysql_fetch_array($query_ht); // THIS WILL ALWAYS RETURN 3 ROWS
//echo json_encode($result); //THis will always contain one row
//echo json_encode($ht_result); // THIS WILL ALWAYS contain 3 ROWS
UPDATE:
//echo json_encode(array(
//'comp' => $result,
//'ht' => $ht_result)
// );
This works, but I dont think it is pretty..... Any suggestions
$query_htl = mysql_query("SELECT * FROM coupon WHERE pid='$result[id]' AND type='L'");
$query_htg = mysql_query("SELECT * FROM coupon WHERE pid='$result[id]' AND type='G'");
$query_htr = mysql_query("SELECT * FROM coupon WHERE pid='$result[id]' AND type='R'");
$ht_resultl = mysql_fetch_assoc($query_htl);
$ht_resultg = mysql_fetch_assoc($query_htg);
$ht_resultr = mysql_fetch_assoc($query_htr);
echo json_encode(array(
'comp' => $result,
'htL' => $ht_resultl,
'htG' => $ht_resultg,
'htR' => $ht_resultr)
);
}
When I am echoing one or the other I am ok.. But i do not know how to return everything to jquery
jquery script:
$('#c_search').submit(function(){
data = ($(this).serialize());
$.ajax({
url: 'actions/get_company.php',
type: 'POST',
data: data,
cache: false,
dataType: 'json',
success: function(selected){
i can call with:
alert(selected.htL.id);