title: how to obtain values by selected id android
body: <p>The below code android code fetches data from mysql and display all the values in it that is it fetch by id. but i want to convert the code instead of fetching all data id let it just fetch selected comment_id = 3 they it will only display values of all related comment of comment _id 3</p>
  
  <pre><code>id             comment_id                  comment
  1                   1                   love this product
  2                   1                   not bad
  3                   2                   too expensive
  4                   2                   how much
  5                   2                   too old
  6                   3                   not that new
  7                   5                   hate it
  8                   7                   go away
  9                   8                   what wrong with you
  10                  4                   hi
  11                  7                   hi
  12                  4                   helo
  13                  7                   hola
  14                  4                   go away
  15                  6                   nice
  16                  3                   bye 
  </code></pre>
  
  <p>so this is the android code</p>
  
  <pre><code>package com.androidjson.serverupdate_androidjsoncom;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class test2 extends AppCompatActivity {
  
      ListView StudentListView;
      ProgressBar progressBar;
      String HttpUrl = "http://192.168.0.199/edit/AllStudentData.php";
      List&lt;String&gt; IdList = new ArrayList&lt;&gt;();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_show_all_students);
  
          StudentListView = (ListView)findViewById(R.id.listview1);
  
          progressBar = (ProgressBar)findViewById(R.id.progressBar);
  
          new GetHttpResponse(test2.this).execute();
  
          //Adding ListView Item click Listener.
          StudentListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
          {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
                  // TODO Auto-generated method stub
  
                  Intent intent = new Intent(test2.this,ShowSingleRecordActivity.class);
  
                  // Sending ListView clicked value using intent.
                  intent.putExtra("ListViewValue", IdList.get(position).toString());
  
                  startActivity(intent);
  
                  //Finishing current activity after open next activity.
                  finish();
  
              }
          });
      }
  
      // JSON parse class started from here.
      private class GetHttpResponse extends AsyncTask&lt;Void, Void, Void&gt; {
          public Context context;
  
          String JSonResult;
  
          List&lt;Student&gt; studentList;
  
          public GetHttpResponse(Context context)
          {
              this.context = context;
          }
  
          @Override
          protected void onPreExecute()
          {
              super.onPreExecute();
          }
  
          @Override
          protected Void doInBackground(Void... arg0)
          {
              // Passing HTTP URL to HttpServicesClass Class.
              HttpServicesClass httpServicesClass = new HttpServicesClass(HttpUrl);
              try
              {
                  httpServicesClass.ExecutePostRequest();
  
                  if(httpServicesClass.getResponseCode() == 200)
                  {
                      JSonResult = httpServicesClass.getResponse();
  
                      if(JSonResult != null)
                      {
                          JSONArray jsonArray = null;
  
                          try {
                              jsonArray = new JSONArray(JSonResult);
  
                              JSONObject jsonObject;
  
                              Student student;
  
                              studentList = new ArrayList&lt;Student&gt;();
  
                              for(int i=0; i&lt;jsonArray.length(); i++)
                              {
                                  student = new Student();
  
                                  jsonObject = jsonArray.getJSONObject(i);
  
                                  // Adding Student Id TO IdList Array.
                                  IdList.add(jsonObject.getString("id").toString());
  
                                  //Adding Student Name.
                                  student.StudentName = jsonObject.getString("name").toString();
  
                                  studentList.add(student);
  
                              }
                          }
                          catch (JSONException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                          }
                      }
                  }
                  else
                  {
                      Toast.makeText(context, httpServicesClass.getErrorMessage(), Toast.LENGTH_SHORT).show();
                  }
              }
              catch (Exception e)
              {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(Void result)
  
          {
              progressBar.setVisibility(View.GONE);
  
              StudentListView.setVisibility(View.VISIBLE);
  
              ListAdapterClass adapter = new ListAdapterClass(studentList, context);
  
              StudentListView.setAdapter(adapter);
  
          }
      }
  }
  </code></pre>
  
  <p>this is my php code</p>
  
  <pre><code>&lt;?php
  
  if($_SERVER['REQUEST_METHOD']=='POST'){
  
  include_once($_SERVER['DOCUMENT_ROOT']."/config/config.php");
  
   $id= $_POST['id'];
  
  // Create connection
  $conn = new mysqli($host, $user, $pass, $database);
  
  if ($conn-&gt;connect_error) {
  
   die("Connection failed: " . $conn-&gt;connect_error);
  }
  
  $sql = "SELECT * FROM comments where comment_id = '$id'" ;
  
  $result = $conn-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt;0) {
  
  
   while($row[] = $result-&gt;fetch_assoc()) {
  
   $tem = $row;
  
   $json = json_encode($tem);
  
   }
  
  } else {
   echo "No Results Found.";
  }
   echo $json;
  
  $conn-&gt;close();
  }
  ?&gt;
  </code></pre>