CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

Android - Récupérer data depuis serveur PHP

_Pytchoun
_Pytchoun
Niveau 67
26 février 2021 à 15:59:18
JsonArrayRequest ExampleRequest = new JsonArrayRequest (Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
            @Override
            public void onResponse(JSONArray response) {
                System.out.println("Request response : " + response);
                TextView textView = (TextView) findViewById(R.id.textView);
                textView.setText(response.toString());
            }
        }, new Response.ErrorListener() { // Create an error listener to handle errors appropriately.
            @Override
            public void onErrorResponse(VolleyError error) {
                // This code is executed if there is an error.
                System.out.println("Request error : " + error);
            }
        });
        ExampleRequestQueue.add(ExampleRequest);

Bonjour,

Comment avoir pour chaque tableau un élément du tableau en particulier ?

Voila ce que ca me sort https://hatebin.com/faasbhuruq

Genre je voudrais récupérer le nom de chaque boutique

<?php
require_once "$_SERVER[DOCUMENT_ROOT]/model/ShopManager.php";

$shopManager = new ShopManager();

// Select shops
$shops = $shopManager->selectShops();

echo json_encode($shops);

Voici le code PHP

_Pytchoun
_Pytchoun
Niveau 67
26 février 2021 à 17:28:28
StringRequest ExampleRequest = new StringRequest (Request.Method.GET, url, new Response.Listener<String>() {
            StringBuilder data = new StringBuilder();
            @Override
            public void onResponse(String response) {
                System.out.println("Request response : " + response);
                try {
                    // converting the string to json array object
                    JSONArray array = new JSONArray(response);

                    // traversing through all the object
                    for (int i = 0; i < array.length(); i++) {
                        // getting shop object from json array
                        JSONObject obj = array.getJSONObject(i);

                        // adding the shop to shop list
                        int shopId = obj.getInt("shop_id");
                        String shopName = obj.getString("shop_name");
                        double shopLat = obj.getDouble("shop_lat");
                        double shopLng = obj.getDouble("shop_lng");
                        System.out.println("Id : " + shopId);
                        System.out.println("Nom : " + shopName);
                        System.out.println("Lat : " + shopLat);
                        System.out.println("Lng : " + shopLng);
                        data = insertShops(data, shopId, shopName, shopLat, shopLng);
                    }
                    try {
                        // saving the file into device
                        FileOutputStream out = openFileOutput("data.csv", Context.MODE_PRIVATE);
                        out.write((data.toString()).getBytes());
                        out.close();
                        printData();
                        updateShopsTable();
                    } catch(Exception e) {
                        e.printStackTrace();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() { // Create an error listener to handle errors appropriately.
            @Override
            public void onErrorResponse(VolleyError error) {
                // This code is executed if there is an error.
                System.out.println("Request error : " + error);
            }
        });
        ExampleRequestQueue.add(ExampleRequest);

Bon j'ai fais ca ca l'air moche mais ca marche

<?php
require_once "$_SERVER[DOCUMENT_ROOT]/model/ShopManager.php";

$shopManager = new ShopManager();

// Select shops
$shops = $shopManager->selectShops();

$shops_array = array();

foreach ($shops as $shop) {
    $temp = array();
    $temp['shop_id'] = $shop['shop_id'];
    $temp['shop_name'] = $shop['shop_name'];
    $temp['shop_lat'] = $shop['shop_lat'];
    $temp['shop_lng'] = $shop['shop_lng'];
    array_push($shops_array, $temp);
}

echo json_encode($shops_array);
Sous forums
  • Aide à l'achat Mac
  • Création de Jeux
  • Linux
  • Création de sites web
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware
La vidéo du moment