1

In my Android project I have a main screen, the Java class associated with this activity holds an 'id' variable, how do I send this 'id' to a PHP so I can then run a query on my database?

Essentially what I want to do is get the 'id' variable from the Java class, then run a query SELECT * FROM table WHERE id = ? on the PHP file.

6
  • you can use json Commented Mar 7, 2017 at 14:26
  • 1
    Send it as string using http post or get request? or as json payload? Commented Mar 7, 2017 at 14:27
  • @frz3993 so something like $id = $_GET["id"] would get the id from the java class and place the string in php $id variable? Commented Mar 7, 2017 at 14:31
  • You can do that if you use Java HttpURLConnection and make a get request to the PHP script. Example :www.example.com/index.php?id=1. Commented Mar 7, 2017 at 14:41
  • @frz3993 I see, but it seems the id numbe is hardcoded in the link? my id variable will be changing string values constantly Commented Mar 7, 2017 at 14:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.