[英]How to Display Data from MySQL Database to Android by inserting it into Table?
[英]How to get total data table from database mysql and display in android
我想顯示從數據庫mysql到android的總數據表,例如表中有5條數據的表路,然后在android textview中顯示為“您的數據:5”,請幫幫我,因為我的textview無法顯示任何內容,這是mycode
try {
JSONArray data_belum = new JSONArray(getJSONUrl(urlDataBelum));
for (int i = 0; i < data_belum.length(); i++) {
try {
JSONObject c = data_belum.getJSONObject(i);
int userId = Integer.parseInt(c.getString("status"));
belum.setText(userId);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
那是我的PHP代碼
$result = mysql_query("SELECT * FROM laporan WHERE status = 'belum diperbaiki'");
$num_rows = mysql_num_rows($result);
$output = array($num_rows);
echo json_encode($output);
這是指R.string中的ID。*
belum.setText(userId);
要顯示整數,請使用String.valueOf()代替:
belum.setText(String.valueOf(userId));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.