Android Question Php question for b4a

tufanv

Expert
Licensed User
Longtime User
Hello

I use a php on server side to retrieve to my b4a app. I have in my php code following :

B4X:
                        $q = "SELECT * FROM tahmincilerintahminleri where username= '".$user."' and Tuttu='2'  ";
                        $r = mysql_query($q);
                        $a = mysql_fetch_assoc($r);
                        $tutmayankar='0';
                        while(($row = mysql_fetch_assoc($r))) {
                             $tutmayankar =  $tutmayankar + $a['guven'];

Here I want to get the sum of the column "guven" for each row with $tutmayankar.. I use while as above. But there is a problem with this. I get the wrong result. I think i am making a mistake in the code. ( I tested it , I add a new row to my sql database with guven column =4 and as a result $tutmayankar increases for 3 for example.

Can you see any problem with the code ?

TY
 

DonManfred

Expert
Licensed User
Longtime User
you are dfining a string
B4X:
$tutmayankar=0;
                        while(($row = mysql_fetch_assoc($r))) {
                             $tutmayankar += $row['guven'];
 
Upvote 0
Top