merhaba mysqle veri ekleyebildim fakat bir türlü tablolardaki veriyi çekemedim. php dosyasından "showarray" verilerini çekmeye çalışıyorum. hata nerede sizce? requestQueue = Volley.newRequestQueue(getApplicationContext());//////gösterme butonu show.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, showUrl, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { System.out.println(response.toString()); try {//php dosyamızda oluşturduğumuz array ismini buraya yazıyoruz "showarray" JSONArray showarray= response.getJSONArray("showarray"); for (int i = 0; i < showarray.length(); i++) { JSONObject showdata= showarray.getJSONObject(i);///showarrayimizde ki isim,soyisim ve dogum verilerini cekip string değişkenlere atıyoruz String isim= showdata.getString("isim"); String soyisim= showdata.getString("soyisim"); String dogum= showdata.getString("dogum"); result.append(isim + " " + soyisim + " " + dogum + " \n"); } result.append("===\n"); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { System.out.append(error.getMessage()); } }); requestQueue.add(jsonObjectRequest); } });
Kod Android'te çalışan Java kodu, yani Android'ten bir sunucudaki php dosyasının sunduğu array verisi mi cekilmeye çalışılıyor? < Bu ileti mini sürüm kullanılarak atıldı >
evet aynen öyle php dosyamda bu : <?php if($_SERVER["REQUEST_METHOD"]=="POST"){ include 'connection.php'; show(); } function show() { global $connect; $query = " Select * FROM deneme"; $result = mysqli_query($connect, $query); $number_of_rows = mysqli_num_rows($result); $temp_array = array(); if($number_of_rows > 0) { while ($row = mysqli_fetch_assoc($result)) { $temp_array[] = $row; } } header('Content-Type: application/json'); echo json_encode(array("showarray"=>$temp_array)); mysqli_close($connect); } ?>