Android Question need help with a mysql command

tufanv

Expert
Licensed User
Longtime User
Hello

In my php code i use :
B4X:
    $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);

i get null for the encoded json I am doing stg wrong but i dont know what. I am not too much experienced with php & my sql
what i am trying to do is :

With first query ($q) I get the list of the users which fullfills the conditions and later for the second hase (q1) and this is where the problem happens, I want to get each users' airline's routes found in q1. I think the problem is at $topac because what i want to do there is find all routes of the airline found in q1 but i get null. Maybe i am using $topac=$a['airline']; wrongly.

Shortly lets say i got 5 users from the first query ($q). I want to get the airline field of those 5 users and execute another query (q1) to get their routes and print 5 records to get the toplam yolcu of each airline

TY
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…