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?
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;
}
}
}