簡體   English   中英

如何從數據庫mysql獲取總數據表並顯示在android中

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM