I have been following Erel mySql tutorial here
I am working on a mySql project
1. Mysql Table (mysqlscore)
I have 3 fields.
1st Field (home)> Int
2nd Field (opp) > Int
3rd Field (comments)> VarChar
I am trying to read the info from the feilds and put them on to a view on my activity.
Field(Home)>= lbhomescore
Field(opp) >= lbOppScore
Field(comments)>= lvComments
I am haveing trouble geting my code to compile and display the info from the mySql table (mysqlscore) in to the views .
I am including my project.
the php file is the same as in the MySql demo that I am following that Erel posted.
I am new to basic4android so I having some trouble learning.
Any help and guidance to help me understand how to achieve this much appreciated .
I am working on a mySql project
1. Mysql Table (mysqlscore)
I have 3 fields.
1st Field (home)> Int
2nd Field (opp) > Int
3rd Field (comments)> VarChar
I am trying to read the info from the feilds and put them on to a view on my activity.
Field(Home)>= lbhomescore
Field(opp) >= lbOppScore
Field(comments)>= lvComments
I am haveing trouble geting my code to compile and display the info from the mySql table (mysqlscore) in to the views .
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim hc As HttpClient
Dim homescore, oppscore As Int
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim lvComments As ListView
Dim scorelist As Int
Type TwoLines (First As String, Second As String)
Dim lbHome As Label
Dim lbhomescore As Label
Dim lbOppScore As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
hc.Initialize("hc")
End If
Activity.LoadLayout("main")
lvComments.AddSingleLine("sdfsdfs")
lvComments.AddSingleLine("sdfsdfs")
lvComments.AddSingleLine("sdfsdfs")
lvComments.AddSingleLine("sdfsdfs")
lvComments.AddSingleLine("sdfsdfs")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub getscores
ExecuteRemoteQuery("SELECT * FROM mysqlscore",scorelist)
End Sub
Sub ExecuteRemoteQuery(Query As String, TaskId As Int)
Dim req As HttpRequest
req.InitializePost2("http://grantspdr.com/score/score.php", Query.GetBytes("UTF8"))
ExecuteRemoteQuery("SELECT * FROM mysqlscore", scorelist)
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim res As String
res = Response.GetString("UTF8")
Log("Response From Server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Dim homescore As Int
homescore = parser.NextArray
For I = 0 To homescore.Size -1
Dim m As Map
m = homescore.get (I)
Dim scores As TwoLines
scores.First= m.Get("home")
scores.Second = m.Get("opp")
lbhomescore = scores.First
lbOppScore = scores.Second
Next
End Sub
the php file is the same as in the MySql demo that I am following that Erel posted.
I am new to basic4android so I having some trouble learning.
Any help and guidance to help me understand how to achieve this much appreciated .