Android Question (solved, thanks) Read db mySQL but not show all the db

Discussion in 'Android Questions' started by f0raster0, Mar 4, 2015.

  1. f0raster0

    f0raster0 Active Member Licensed User

    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:
    Sub Activity_Create(FirstTime As Boolean)
    Activity.Title ="Playing with php/MySql"

    End Sub

    Sub JobDone(Job As HttpJob)
    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
    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
    If ListOfPersons.Size=0 Then
                        PersonsListview.AddSingleLine (
    "No persons found...")
    For i = 0 To ListOfPersons.Size - 1
    Dim Person As Map
                            Person = ListOfPersons.Get(i)                                         
                            PersonID = Person.Get(
                            PersonContact = Person.Get(
                            PersonCar = Person.Get(
                            PersonsListview.AddSingleLine (PersonID & 
    ", " & PersonContact & ", " & ",Car: " & PersonCar)

    End If     
    End Select
    ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    End Sub

    Sub Button1_Click
    Dim GetPersons As HttpJob
    "GetP", Me)
    "" , Array As String ("action""GetPersons"))
    End Sub
    Sub Button2_Click

    End Sub


    $con = mysql_connect($databasehost,$databaseusername,$databasepassword) 
    or die(mysql_error());
    or die(mysql_error());

    $action = $_GET[
    switch ($action)
    Case "GetPersons":
            $q = mysql_query(
    "SELECT ID, contact, car FROM booking");
            $rows = 
    while($r = mysql_fetch_assoc($q))
                $rows[] = $r;
            print json_encode($rows);

    Last edited: Mar 15, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. f0raster0

    f0raster0 Active Member Licensed User

    ok Erel thanks, I will return to your example.. :oops:
    Edit: trying Erel's example

    I have an error here, line 78: NumberFormat2, because I have replaced "population" for "address"
    lblPopulation.Text = NumberFormat2(m.Get("address"),0, 0, 0, True) & " (K)"

    <!-- Hosting24 Analytics Code -->

    type="text/javascript" src=""></script>

    End Of Analytics Code -->

    Response from 
    server: [{"address":"Larnach Castle Lodge"}]

    <!-- Hosting24 Analytics Code -->

    <script type="text/javascript" src=""></script>

    <!-- End Of Analytics Code -->

    java.lang.NumberFormatException: Invalid double: "Larnach Castle Lodge"
        at java.lang.StringToReal.invalidReal(
        at java.lang.StringToReal.initialParse(
        at java.lang.StringToReal.parseDouble(
        at java.lang.Double.parseDouble(
        at anywheresoftware.b4a.BA.ObjectToNumber(
        at Antu.php.samples.mysql.main._jobdone(
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(
        at anywheresoftware.b4a.BA.raiseEvent2(
        at anywheresoftware.b4a.keywords.Common$
        at android.os.Handler.handleCallback(
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(
        at dalvik.system.NativeStart.main(Native Method)
    running waiting messages (2)
    ** Activity (main) Resume **
    ** Activity (main) Pause, UserClosed = true **
    Last edited: Mar 4, 2015
  4. sorex

    sorex Expert Licensed User

    stick to what you already had, Erel's code is not safe to use.

    GetPersons.download2("" , Array As String ("action""GetPersons","shuttle"2))
    Case "GetPersons":
     $q = mysql_query(
    "SELECT ID, contact, shuttle FROM booking where shuttle=".$shuttle;
    f0raster0 and Cableguy like this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    The php script posted in the MySQL tutorial is safe to use if you understand what it does and how the server should be configured.

    Otherwise I wouldn't have publicly run this script on this server.
    NJDude likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice