Android Question How to pass a list/array in a URL?

Discussion in 'Android Questions' started by tsteward, Mar 3, 2015.

  1. tsteward

    tsteward Active Member Licensed User

    If I pass data to a php file which searches my database and returns a result, all works well.
    How do I go about searching the same data in multiple tables.

    Code:
    getCodes.download2("http://locksdownxxx.com/codes.php"Array As String ("Action""FindBitting","Table",codetable,"SchData",srchString))
    Above works fine to search one table.
    How would I go about sending more than one table name to search and how would I deal with that in my php file?
     
  2. little3399

    little3399 Active Member Licensed User

    maybe U can use the JSON
     
  3. tsteward

    tsteward Active Member Licensed User

  4. sorex

    sorex Expert Licensed User

    you need to rewrite your PHP file for it.
     
  5. tsteward

    tsteward Active Member Licensed User

    OK none of this has been any help guys?
     
  6. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Just make codetable=table1 & "|" & table2 & ...
    And parse codetable in your php.

    Hard to tell without seeing your php
     
  7. sorex

    sorex Expert Licensed User

    you shouldn't send over full queries or table names.

    like I said before you should rewrite the php file.
     
  8. thedesolatesoul

    thedesolatesoul Expert Licensed User

    So how would you avoid sending a tablename? (and how would you know it is a tablename just from the params?)
     
  9. sorex

    sorex Expert Licensed User

    you use a switch on the option/action parameter name.

    with that you know what to query and which extra parameters to use from the query string or post.
     
  10. KMatle

    KMatle Expert Licensed User

  11. thedesolatesoul

    thedesolatesoul Expert Licensed User

    So what does that accomplish? Hiding the table name?
     
  12. tsteward

    tsteward Active Member Licensed User

    Ok here is some of my code. I'm happy to re-write to a better way but I need help on how to do it.
    Just to recap I want supply multiple tables for the php file to search for the data "Biting"

    B4A code
    Code:
    getCodes.download2("http://locksdownxxx.com/codes.php"Array As String ("Action""FindBitting","Mail",Main.manager.GetString("UsersEmail"),"ID",Main.phid.GetDeviceId,"Table",codetable,"Biting",srchString))
    PHP File. I have marked Start and End where I open a table and search it then return the result.
    Code:
    $action = $_GET["Action"];
    switch ($action)
        {
        
    case "FindBitting":
            $mail=$_GET[
    "Mail"];
            $
    id = $_GET["ID"];
            $table = $_GET[
    "Table"];
            $bitting = $_GET[
    "Biting"];
           
            $q = mysql_query(
    "SELECT * FROM users Where mail = '$mail' OR DeviceID = '$id'");
            $count = mysql_num_rows($q);
            
    if ($count == 0#if no match to email found in DB
            {
                print json_encode ("UserError");
                break;
            }
            else
            {
                $row = mysql_fetch_array($q);
                if ($row['subscribed'] == "1")  # can only continued if subscribed
                {
    # **** Start here ***********
                    $rs = mysql_query("SELECT Code, Bitting FROM $table Where bitting LIKE '$bitting'");
                    $counter = mysql_num_rows($rs);
                    $rows = array();
                    while($r = mysql_fetch_assoc($rs))
                        {
                            $rows[] = $r;
                        }
                    print json_encode($rows);
    # **** End Here **************
                    break;
                }
                else {
                    print json_encode ("NotSubscribed");
                    break;
                    }   
            }       
        }
     
  13. tsteward

    tsteward Active Member Licensed User

    I know I shouldn't bump posts but I really need some help here. I just don't know how to achieve this.
     
Loading...
  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