使用curl和json从数据库中获取数据

Do any of you know a way to get datas from a database of a website? I already studied and made a program that POST data using json. It gets the shipment status of a certain tracking number and if it's shipped, it will be changed to delivered. And I already done that.

Now what I'm trying to do is get all the datas, or the row of that tracking number and then encode it to JSON. But I don't know what to do.

This is how I did the first program: on getting a specific tracking number and update the status to delivered.

<?php

$url='https://sample.com.ph';
$apikey='apikey';
$method ='SendPackageStatus';


    $data = array(
        'package'   => array(
             'tracking_number'  =>  '735898532',
             'package_status'    => 'delivered',
             'failed_reason'     => '',
             'updated_at'        => '2014-01-01 07:02:14'
         )
     );
     $check=json_encode($data);

     $postdata = "&data=$check&apikey=$apikey&method=$method";
     $ch = curl_init();

    curl_setopt_array(
        $ch,
        array(

            CURLOPT_URL => $url.'/webservice/',
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_FOLLOWLOCATION  => true,
            CURLOPT_VERBOSE         => true,
            CURLOPT_POST => 1,
        CURLOPT_POSTFIELDS      => $postdata,
        CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_HTTPHEADER => array('Content-type:  application/x-www-form-urlencoded', 

            )
        )
    );


     $result = curl_exec($ch);
     curl_close($ch);
     echo $result;



?>

Why not use mysql?... you can store json string on db (as..strings). I dont follow what you are trying to do.