Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:56:11+00:00 2026-05-31T07:56:11+00:00

I had some problem understanding the following line of code. What exactly does it

  • 0

I had some problem understanding the following line of code. What exactly does it do and how does it help me query the database from android

$q=mysql_query("SELECT * FROM people WHERE birthyear>'".$_REQUEST['year']."'");
while($e=mysql_fetch_assoc($q))
    $output[]=$e;
print(json_encode($output));

I know the initial part of it means select every record from table people where birthyear…

But after that I get confused. I am calling this php function from android using http post

ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("year","1980")); 
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/retrieve.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost); 
HttpEntity entity = response.getEntity();
is = entity.getContent();

Where is an input stream. Can someone help me out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:56:13+00:00Added an answer on May 31, 2026 at 7:56 am

    The PHP code queries the database and constructs a JSON output, which it sends to the calling client. Try calling the php from a browser (put the URL in the address bar) – and you should get the JSON back.

    On the Android side, java code is using HTTPClient wrapper to call your php and get the response. Socket (HTTP connection) InputStream is handled internally by HttpClient when you call relevant methods. From your point of view, all you need to do is deal with the content of the entity.

    You can just open the input stream from the entity (your is variable) and read the data from it:

    InputStream is = entity.getContent();
    

    then read the content of the stream as you normally would. You should get the json as was sent by the php.

    PHP gets the value of required minimum year from year request parameter. In android, a NameValuePair is created with name=year and value=1980. This NameValuePair is passed as POST parameter in the form year=1980 to the PHP code. Again, this is handled internally by the HTTPClient wrapper class. Then the PHP code reads the value of request parameter “year” to get the minimum value for the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with some code I've written. I've had to anonymize it,
Need some help with this problem in implementing with XSLT, I had already implemented
I had this problem some time ago and I gave up but lately it
I have a little problem. I had some JComboBox to a JDialog but they
I had a performance problem today that showed up after some profiling. Calls to
I had recently a problem with oom-killer starting to kill processes after some time.
I recently had a problem in my app where some of the subviews I
I'm currently working on some MPI code for a graph theory problem in which
I'm building a python application from some source code I've found Here I've managed
I had some problems with my subversion server and i had to restore it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.