Skip to content
Advertisement

Android Volley: select data from MySQL database by id specified by user

I’m writing a simple Android application using Volley. I’d like to know how to select a first name and a last name from MySQL database by ID, which user enter into editText in application. This is my PHP script:

JavaScript

If I specified the ID in the code, it returns a data in JSON, which I demand, so the script and the database are ok. The response which I get for $id=1 is:

JavaScript

And this is my code of StringRequest:

JavaScript

Unfortunately, it doesn’t do anything… It even doesn’t show any error or toast message. Do you know how to fix it?

Advertisement

Answer

{“users”:[{“firstName”:”Jonash”,”lastName”:”Corvin”}]}

According to the given JSON you need to parse the JSON like this:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement