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

tsteward

Well-Known 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.

B4X:
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?
 

tsteward

Well-Known Member
Licensed User
OK none of this has been any help guys?
 

sorex

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

like I said before you should rewrite the php file.
 

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.
 

tsteward

Well-Known 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
B4X:
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.
B4X:
$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;
                }   
        }       
    }
 

tsteward

Well-Known 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.
 
Top