$q = "SELECT * from users where base = '".$adaminbase."' OR base2 = '".$adaminbase."'";
$r = mysql_query($q);
$a = mysql_fetch_assoc($r);
$all = array();
while(($row = mysql_fetch_assoc($r))) {
$topac=$a['airline'];
$q1 = "SELECT departure,destination,airline,SUM(yolcu) AS toplamyolcu FROM userroutes1 WHERE (DEPARTURE = '".$adaminbase."' OR DESTINATION = '".$adaminbase."') and airline='".$topac."' group by airline";
$r1 = mysql_query($q1);
$row2 = mysql_fetch_assoc($r1);
$all[] = $row2;
}
print json_encode($all);