tsteward Well-Known Member Licensed User Longtime User Mar 3, 2015 #1 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: Copy 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?
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: Copy 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?
little3399 Active Member Licensed User Longtime User Mar 3, 2015 #2 maybe U can use the JSON Upvote 0
S sorex Expert Licensed User Longtime User Mar 3, 2015 #4 you need to rewrite your PHP file for it. Upvote 0
tsteward Well-Known Member Licensed User Longtime User Mar 3, 2015 #5 OK none of this has been any help guys? Upvote 0
thedesolatesoul Expert Licensed User Longtime User Mar 3, 2015 #6 Just make codetable=table1 & "|" & table2 & ... And parse codetable in your php. Hard to tell without seeing your php Upvote 0
Just make codetable=table1 & "|" & table2 & ... And parse codetable in your php. Hard to tell without seeing your php
S sorex Expert Licensed User Longtime User Mar 3, 2015 #7 you shouldn't send over full queries or table names. like I said before you should rewrite the php file. Upvote 0
you shouldn't send over full queries or table names. like I said before you should rewrite the php file.
thedesolatesoul Expert Licensed User Longtime User Mar 3, 2015 #8 sorex said: you shouldn't send over full queries or table names. like I said before you should rewrite the php file. Click to expand... So how would you avoid sending a tablename? (and how would you know it is a tablename just from the params?) Upvote 0
sorex said: you shouldn't send over full queries or table names. like I said before you should rewrite the php file. Click to expand... So how would you avoid sending a tablename? (and how would you know it is a tablename just from the params?)
S sorex Expert Licensed User Longtime User Mar 3, 2015 #9 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. Upvote 0
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.
KMatle Expert Licensed User Longtime User Mar 3, 2015 #10 See here: https://www.b4x.com/android/forum/t...ring-via-job-download2-to-a-php-script.50919/ Upvote 0
thedesolatesoul Expert Licensed User Longtime User Mar 3, 2015 #11 sorex said: 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. Click to expand... So what does that accomplish? Hiding the table name? Upvote 0
sorex said: 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. Click to expand... So what does that accomplish? Hiding the table name?
tsteward Well-Known Member Licensed User Longtime User Mar 3, 2015 #12 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: Copy 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: Copy $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; } } } Upvote 0
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: Copy 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: Copy $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 Longtime User Mar 4, 2015 #13 I know I shouldn't bump posts but I really need some help here. I just don't know how to achieve this. Upvote 0
I know I shouldn't bump posts but I really need some help here. I just don't know how to achieve this.