title: Post parameter to PHP file
body: <p>I have a code snippet which helps me to get data from my mySQL database. It also works fine ! But now I want to add parameters for my sql query because until now this code only works for this :</p>
  
  <blockquote>
    <p>mysql_query("SELECT * FROM tablename ORDER BY 5 DESC");</p>
  </blockquote>
  
  <p>So everything is being outputed.For example I want to use a query like this :</p>
  
  <blockquote>
    <p>mysql_query("SELECT * FROM tablename WHERE name LIKE "a%" ORDER BY 5 DESC");</p>
  </blockquote>
  
  <p>That is my code snippet in Android :</p>
  
  <pre><code>    public class get_data extends AsyncTask&lt;Void, Void, Boolean&gt;
  {
  
      @Override
      protected Boolean doInBackground(Void... params) {
  
          String result = null;
          InputStream is = null;
          StringBuilder sb = null;
  
          str_name_list = new ArrayList&lt;String&gt;();
          str_nname_list = new ArrayList&lt;String&gt;();
  
          try {
              HttpClient httpclient = new DefaultHttpClient();
              HttpPost httppost = new HttpPost("Here is my Link");
              HttpResponse response = httpclient.execute(httppost);
              HttpEntity entity = response.getEntity();
              is = entity.getContent();
          } catch (Exception e) {
              Log.e("log_tag", "Error in http connection" + e.toString());
          }
          // convert response to string
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              sb = new StringBuilder();
              sb.append(reader.readLine() + "\n");
              String line = "0";
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              result = sb.toString();
          } catch (Exception e) {
              Log.e("log_tag", "Error converting result " + e.toString());
          }
          // paring data
          JSONArray jArray;
          try {
              jArray = new JSONArray(result);
              JSONObject json_data = null;
  
              int anz = jArray.length();
              if (anz &gt; 15)
                  anz = 15;
  
  
              for (int i = 0; i &lt; anz ; i++) {
                  json_data = jArray.getJSONObject(i);
                  str_name_list.add(json_data.getString("NAME"));
                  str_nname_list.add(json_data.getString("AGE"));
              }
          } catch (JSONException e1) {
  
          } catch (ParseException e1) {
              e1.printStackTrace();
          }
  
  
          return null;
      }
  }
  </code></pre>
  
  <p>I found out that I have to add it in HttpEntity but really dont know how without to destroy my code. Thanks in advance !</p>