title: get data from database using curl and json
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>This is how I did the first program: on getting a specific tracking number and update the status to delivered.</p>
  
  <pre><code>&lt;?php
  
  $url='https://sample.com.ph';
  $apikey='apikey';
  $method ='SendPackageStatus';
  
  
      $data = array(
          'package'   =&gt; array(
               'tracking_number'  =&gt;  '735898532',
               'package_status'    =&gt; 'delivered',
               'failed_reason'     =&gt; '',
               'updated_at'        =&gt; '2014-01-01 07:02:14'
           )
       );
       $check=json_encode($data);
  
       $postdata = "&amp;data=$check&amp;apikey=$apikey&amp;method=$method";
       $ch = curl_init();
  
      curl_setopt_array(
          $ch,
          array(
  
              CURLOPT_URL =&gt; $url.'/webservice/',
              CURLOPT_SSL_VERIFYPEER =&gt; false,
              CURLOPT_FOLLOWLOCATION  =&gt; true,
              CURLOPT_VERBOSE         =&gt; true,
              CURLOPT_POST =&gt; 1,
          CURLOPT_POSTFIELDS      =&gt; $postdata,
          CURLOPT_RETURNTRANSFER =&gt; 1,
              CURLOPT_HTTPHEADER =&gt; array('Content-type:  application/x-www-form-urlencoded', 
  
              )
          )
      );
  
  
       $result = curl_exec($ch);
       curl_close($ch);
       echo $result;
  
  
  
  ?&gt;
  </code></pre>