I am following the KMatle's tutorials
my dbbase has three columns:
ID contact shuttle
1 person1 2
2 person2 3
3 person3 2
4 person4 1
How could I show in my App only the file where shuttle=2 ?
I don't have idea how I could do it. Thanks in advance
My code is same as the tutorials:
php:
my dbbase has three columns:
ID contact shuttle
1 person1 2
2 person2 3
3 person3 2
4 person4 1
How could I show in my App only the file where shuttle=2 ?
I don't have idea how I could do it. Thanks in advance
My code is same as the tutorials:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
Activity.Title ="Playing with php/MySql"
End Sub
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 PersonID As Int
Dim PersonContact As String
Dim PersonCar As String
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)
PersonID = Person.Get("ID")
PersonContact = Person.Get("contact")
PersonCar = Person.Get("car")
PersonsListview.AddSingleLine (PersonID & ", " & PersonContact & ", " & ",Car: " & PersonCar)
Next
End If
End Select
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub Button1_Click
Dim GetPersons As HttpJob
GetPersons.Initialize("GetP", Me)
GetPersons.download2("http://androidatest.site88.net/Test4.php" , Array As String ("action", "GetPersons"))
End Sub
Sub Button2_Click
End Sub
php:
B4X:
<?php
$databasehost="mysql1.000webhost.com";
$databaseusername="x";
$databasepassword="x";
$databasename="x";
$con = mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error());
mysql_select_db($databasename) or die(mysql_error());
$action = $_GET["action"];
switch ($action)
{
Case "GetPersons":
$q = mysql_query("SELECT ID, contact, car FROM booking");
$rows = array();
while($r = mysql_fetch_assoc($q))
{
$rows[] = $r;
}
print json_encode($rows);
break;
}
?>
Last edited: