I create a project for my work, and I need to filter by User the data store on MySQL and sent to a listview with this:
MainActivity
public class pendientes extends AppCompatActivity{
//tvuser is elegible: John, Mike, etc
TextView tvuser;
private static final String BASE_URL = "http://jjj.freeoda.com/json_user_fetch.php?user=";
private static final String USUARIO = tvuser.getText().toString()+"";
private static final String apiurl = BASE_URL + USUARIO;
But I receive the follow error message: Non-static field 'USUARIO' cannot be referenced from a static context
DB MySQL:
ID | Person | User |
---|---|---|
1 | Juan Lopez | jhon |
2 | Esteban Morales | mike |
3 | Luis Miguel | jhon |
4 | Juan Gabriel | jhon |
In example, if I choose John, my listview only populate with: Juan Lopez Luis Miguel Juan Gabriel
If I choose Mike the results: Esteban Morales
My PHP API
<?php
$conn=mysqli_connect("localhost","user","pass");
mysqli_select_db($conn,"dbname");
$user=$_GET['user'];
$qry="select * from jurado where user= '$user'";
$raw=mysqli_query($conn,$qry);
while($res=mysqli_fetch_array($raw))
{
$data[]=$res;
}
print(json_encode($data));
?>
How could I do to send a variable data (USER) to URL?