Advertisement
EndymionSpr

Untitled

Jan 11th, 2021
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2.   // Headers
  3.   header('Access-Control-Allow-Origin: *');
  4.   header('Content-Type: application/json');
  5.  
  6.   include_once '../../config/Database.php';
  7.   include_once '../../models/Trades.php';
  8.  
  9.   // Instantiate DB & connect
  10.   $database = new Database();
  11.   $db = $database->connect();
  12.  
  13.   // Instantiate blog trades object
  14.   $trades = new Trades($db);
  15.  
  16.   // Get ID
  17.   $data = json_decode(file_get_contents("php://input"));
  18.  
  19.   $trades->id = $data->id;
  20.  
  21.   // Get trades
  22.   $trades->single_trade_info();
  23.  
  24.   // Create array
  25.   $post_arr = array(
  26.     'plant_type' => $trades->plant_type,
  27.     'owner_id' => $trades->owner_id,
  28.     'name' => $trades->name,
  29.     'town' => $trades->town,
  30.     'phone' => $trades->phone,
  31.     'descryption' => $trades->descryption,
  32.     'transaction_type' => $trades->transaction_type
  33.   );
  34.  
  35.   // Make JSON
  36.   print_r(json_encode($post_arr));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement