title: How to have a filter data from database to listview using php mysql?
body: <p>Hi guys I have a <code>Listview</code> the will get details from my <code>database using php</code> but <code>I want the poster will see their own posts on the database</code> I used the one-to-many relationship by the username because It is saved on the sharedpreference.</p>
  
  <p>Well here are my codes. </p>
  
  <p>getting the data from database. </p>
  
  <pre><code>&lt;?PHP
  include_once("connection.php");
  
  $query = "SELECT * FROM car_category ORDER BY Car_No DESC"; 
  
  $result = mysqli_query($conn, $query);
  
  while($row = mysqli_fetch_assoc($result)){
          $data[] = $row;
  }
  echo json_encode($data);
  ?&gt;
  </code></pre>
  
  <p>My Listview.</p>
  
  <pre><code>public class ownerhome extends AppCompatActivity implements AsyncResponse, AdapterView.OnItemClickListener {
  final String TAG = this.getClass().getName();
  private ArrayList&lt;Cars&gt; carList;
  private ListView lvCars;
  private FunDapter&lt;Cars&gt; adapter;
  SharedPreferences pref;
  SharedPreferences.Editor editor;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_ownerhome);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      ImageLoader.getInstance().init(UILConfig.config(ownerhome.this));
      PostResponseAsyncTask taskRead = new PostResponseAsyncTask(ownerhome.this, this);
      taskRead.execute("http://carkila.esy.es/user.php");
  
      lvCars = (ListView) findViewById(R.id.lvOnwer);
  
  
  
      pref = getSharedPreferences("Login.conf", Context.MODE_PRIVATE);
  
      Log.d(TAG, pref.getString("username", ""));
      Log.d(TAG, pref.getString("password", ""));
  
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Intent in = new Intent(ownerhome.this, InsertActivity.class);
              startActivity(in);
          }
      });
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater findMenuItems = getMenuInflater();
      findMenuItems.inflate(R.menu.menu_main, menu);
      return super.onCreateOptionsMenu(menu);
  
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      int id = item.getItemId();
  
      if(id == R.id.action_logout){
          editor = pref.edit();
          editor.clear();
          editor.commit();
          Intent in = new Intent(ownerhome.this, MainActivity.class);
          startActivity(in);
          finish();
      }
      return super.onOptionsItemSelected(item);
  }
  
  
  @Override
  public void processFinish(String s) {
      Log.d(TAG, s);
  
      carList = new JsonConverter&lt;Cars&gt;().toArrayList(s,Cars.class);
  
      BindDictionary&lt;Cars&gt; dict = new BindDictionary&lt;Cars&gt;();
  
      dict.addDynamicImageField(R.id.ivImg, new StringExtractor&lt;Cars&gt;() {
          @Override
          public String getStringValue(Cars product, int position) {
              return product.Image;
          }
      }, new DynamicImageLoader() {
          @Override
          public void loadImage(String url, ImageView imageView) {
  
              ImageLoader.getInstance().displayImage(url, imageView); // Default options will be used
  
          }
      });
      dict.addStringField(R.id.tvCarModel, new StringExtractor&lt;Cars&gt;() {
          @Override
          public String getStringValue(Cars product, int position) {
              return "Car Model: " + product.Car_Model;
          }
      });
      dict.addStringField(R.id.tvCarType, new StringExtractor&lt;Cars&gt;() {
          @Override
          public String getStringValue(Cars product, int position) {
              return "Car Type: " + product.Car_Type;
          }
      });
  
      dict.addStringField(R.id.tvCapacity, new StringExtractor&lt;Cars&gt;() {
          @Override
          public String getStringValue(Cars product, int position) {
              return "Capacity: " + product.Capacity;
          }
      });
      dict.addStringField(R.id.tvFuelType, new StringExtractor&lt;Cars&gt;() {
          @Override
          public String getStringValue(Cars product, int position) {
              return "Fuel Type: " + product.FuelType;
          }
      });
      dict.addStringField(R.id.tvPlateNumber, new StringExtractor&lt;Cars&gt;() {
          @Override
          public String getStringValue(Cars product, int position) {
              return "Plate Number: " + product.PlateNumber;
          }
      });
      dict.addStringField(R.id.tvPoster, new StringExtractor&lt;Cars&gt;() {
          @Override
          public String getStringValue(Cars product, int position) {
              return "Posted by: " + product.owner;
          }
      });
  
  
  adapter = new FunDapter&lt;&gt;(
          ownerhome.this, carList, R.layout.layout_list, dict);
  
  lvCars.setAdapter(adapter);
  lvCars.setOnItemClickListener(this);
  
  }
  
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
      Cars selectedCars = carList.get(position);
      Intent in = new Intent(ownerhome.this, DetailActivity.class);
      in.putExtra("cars", selectedCars);
      startActivity(in);
  }
  }
  </code></pre>