将这些数据存储在我的数据库中,并且某些用户具有相同的DEPT值。我的目标是登录用户登录页面(即A1)。它仅显示具有相同dept值的所有用户,只有A1,B1,E1 。
Settings
但问题是我的user_id和dept输出数据是在JAVA Android Studio 。
另外,在这种情况下,应用 request.GET 而不是POST。
JAVA文件
class Settings
def self.globalSettings(totalmoney, nplayer)
@@totalmoney = totalmoney
end
def self.totalmoney
@@totalmoney
end
end
class Player
def initialize(kingdom, king)
@playerData = [kingdom, king]
end
def calculate
print Settings.totalmoney
end
end
Settings.globalSettings(100, 2)
player_fabrizio = Player.new("MyDinasty", "Fabrizio")
player_fabrizio.calculate
有可能还是我做错了?
还有我的PHP文件,如下所示。
PHP文件
---------------------------
| id | user_id | dept |
---------------------------
| 1 | A1 | ITD |
| 2 | B1 | ITD |
| 3 | C1 | FAD |
| 4 | D1 | PNC |
| 5 | E1 | ITD |
| 6 | F1 | PSSB |
Config.class
public class Test extends AppCompatActivity{
public static final String dept = "DEPT";
public static final String user_id = "ID";
@Override
protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
Bundle extras = intent.getExtras();
final String dept = (String) extras.get("DEPT");
final String user_id = (String) extras.get("USERID");
getData();
}
private void getData(){
String url = "https://www.aaa.com/test.php";
StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject j = null;
try{
j = new JSONObject(response);
result = j.getJSONArray(Config.JSON_ARRAY);
getStaffs(result);
}catch (JSONException e){
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(Test.this);
requestQueue.add(stringRequest);
}
}
感谢。