I have an example app that insert data with php file and b4a
insert , update and delete are ok.
but select a row and show data in edittext I do not know how to do it .. I searched before this thread
could you tell me about that and give me advice .
my php file for insert
Thanks alot
insert , update and delete are ok.
but select a row and show data in edittext I do not know how to do it .. I searched before this thread
could you tell me about that and give me advice .
my php file for insert
B4X:
case "InsertNewPerson":
$name = $_POST["name"];
$age = $_POST["age"];
$img= $_POST["img"];
$q = mysql_query("INSERT INTO persons (name, age, img) VALUES ('$name', '$age', '$img')");
print json_encode("Inserted");
break;
and code b4a for insert this
Dim InsertNewPerson As HttpJob
InsertNewPerson.Initialize("InsertNewP", Me)
InsertNewPerson.postString("http://" & ServerIP & "/persons.php","action=InsertNewPerson&name="&NameET.Text&"&age="&AgeET.Text&"&img="&img64)
until now no problem
my question : how to do select row and display data and image on edittext and imageview
this php file for select
case "SelectPersons":
$name = $_POST["name"];
$age = $_POST["age"];
$img= $_POST["img"];
$q = mysql_query("select * from persons where name='$name'");
print json_encode("Selected");
break;
what I write the code b4a to select row ?
this is code b4a
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
Log("Back from Job:" & Job.JobName )
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case "GetP"
Dim ListOfPersons As List
Dim PersonName As String
Dim PersonAge As Int
ListOfPersons = parser.NextArray 'returns a list with maps
PersonsListview.Clear
If ListOfPersons.Size=0 Then
PersonsListview.AddSingleLine ("No persons found...")
Else
For i = 0 To ListOfPersons.Size - 1
Dim Person As Map
Person = ListOfPersons.Get(i)
PersonName = Person.Get("name")
PersonAge = Person.Get("age")
PersonsListview.AddSingleLine (PersonName & ", " & PersonAge)
Next
End If
Case "CountP"
PersonsListview.AddSingleLine ("Persons in table: " & parser.NextValue)
End Select
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Thanks alot