Hello.
i have follow this tutorial, and i'm try to modify the example filefrom this post:
i need to pick a single value from table. The table is for user fields and have many fields like (name, surname,,address, city, energy, etc.)
i would like pick the value "energy" from name with id "pippo"
So this is my code:
on php file, this is the code:
now, onthe edittext, it show:
But no other errors
i have follow this tutorial, and i'm try to modify the example filefrom this post:
B4X:
https://www.b4x.com/android/forum/threads/complete-tutorial-b4a-your-own-local-php-mysql-server-xampp-with-b4a.48635/
i need to pick a single value from table. The table is for user fields and have many fields like (name, surname,,address, city, energy, etc.)
i would like pick the value "energy" from name with id "pippo"
So this is my code:
B4X:
Public Sub pickEnergy
Dim DoUsersEnergy As HttpJob
DoUsersEnergy.Initialize("", Me)
DoUsersEnergy.download2("http://192.168.1.43/persons/persons.php", Array As String ("action", "GetUserEnergy","deviceid",functions.GetDeviceId))
Wait For (DoUsersEnergy) JobDone(DoUsersEnergy As HttpJob)
If DoUsersEnergy.Success Then
Dim res As String
res = DoUsersEnergy.GetString
Log("Back from Job:" & DoUsersEnergy.JobName )
Log("Response from server: " & res)
Dim l As List
l.Initialize
Dim parser As JSONParser
parser.Initialize(res)
[S] l.Add(parser.NextValue) [/S]l.Add(parser.NextObject) ' suggest from [B][USER=73327]le_toubib[/USER][/B]
Log(l.Size)
Log(l.Get(0))
energy_Label.Text = "Total energy: " & l.Get(0) & "/50"
Else
ToastMessageShow("Error: " & DoUsersEnergy.ErrorMessage, True)
End If
DoUsersEnergy.Release
End Sub
on php file, this is the code:
B4X:
case "GetUserEnergy":
$txtdeviceid =$_GET["deviceid"];
$q = mysqli_query($con,"SELECT my_energy FROM tbl_users WHERE my_deviceid = '$txtdeviceid'" );
$rows = array();
print json_encode($q);
break;
now, onthe edittext, it show:
B4X:
{current_field=null, field_count=null, lengths=null, num_rows=null, type=null}
But no other errors
Last edited: