Hello, I am learning the jokhttputils2 library in B4J and have managed to request queries from a mySQL database located on a server. It's easy to read one cell, however when I read all data in i.e Firstname, I've noticed that all names is sent as a long string in job1.GetString so that when put in a TableView all items is treated as one long string even if I add print $row["Firstname"] . chr(13);
Will I have to split the string job1.GetString with regex in JobDone sub or is JSON the solution?
This problem make it impossible to click on a single line in TableView since all added items is treated as one long string. Please help me!!
Only relevant parts from code is shown
B4J
B4X:
job1.Initialize("Job1", Me)
job1.Download("http://www.mydomain.com/test.php")
PHP:
$sql = "SELECT Firstname FROM Contacts";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
print $row["Firstname"] . chr(13);
}
} else {
echo "0 results";
}
$conn->close();
B4J
B4X:
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
'Log(Job.GetString)
TableView1.SetColumns(Array As String("Column 1", "Column 2", "Column 3"))
Row(0) = "a"
Row(1) = "b"
Row(2) = "c"
Row(0) = job1.GetString
TableView1.Items.Add(Row)
Last edited: