ANDROID / PHP: Spinner cannot populate data from MySQL-ThrowExceptions

Exception or error:

Currently, I created android apps that have a spinner. This spinner populated data from MySQL. For now, the spinner can list all the data. Below is my current code:




    $query = $conn->prepare("SELECT * FROM ot_factory ORDER BY fac_id ASC");

    // $query = callApi9();

    $factoryList = array();

    while ($row = $query->fetch(PDO::FETCH_ASSOC)) {



    echo json_encode(array('result'=>$factoryList));


Now, I want to change the query format to JSON. The Api as follows:



    function callApi9(){
        $url = "";
        $data = file_get_contents($url);
        $json = json_decode($data);
        return $json->otFactoryList;


Can I know how to implement this “api.php” into “spinner_factory.php”

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *