So I put a function in my php function code which was
public function getName($name){
$result = mysql_query("SELECT * FROM 'users' WHERE 'name' = '$name' or trigger_error(mysql_error());
return "$result"; }
Edit: my question is how do I call this code in my android class so that I can put that result in an arraylist which is my ultimate goal.
I am trying to get all the names in that column and put them in an array list. And so in my activity android class i put this code.
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
RequestInterface requestInterface = retrofit.create(RequestInterface.class);
User user = new User();
user.setName(name);
user.setEmail(email);
user.setPassword(password);
usernames.add(name);
ServerRequest request = new ServerRequest();
request.setOperation(Constants.REGISTER_OPERATION);
request.setUser(user);
Call<ServerResponse> response = requestInterface.operation(request);
response.enqueue(new Callback<ServerResponse>() {
@Override
public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) {
ServerResponse resp = response.body();
Snackbar.make(getView(), resp.getMessage(), Snackbar.LENGTH_LONG).show();
progress.setVisibility(View.INVISIBLE);
}
I am not sure if this is right, any help would be much appreciated!
Aucun commentaire:
Enregistrer un commentaire