<?php

/*REFERÊNCIAS*/
/*https://www.w3schools.com/js/js_json_php.asp*/
/*https://secure.php.net/manual/pt_BR/book.json.php*/



	$host = "mysql02.ibdeias.hospedagemdesites.ws";
	$user = "ibdeias1";
	$pass = "rootbanco";
	$database = "ibdeias1";
	$conexao = mysqli_connect($host, $user, $pass, $database) or die(mysqli_error($conexao) . "<br>Erro na query: <br>");
	mysqli_select_db($conexao, $database) or die (mysqli_error($conexao) . "<br>Erro na query: <br>");
  
    $consulta = "SELECT 'idprova'           as rideid, 
                        'colete'           as startnumber
                 FROM dual";
  
//echo "olalalalalaa";
      $resultado = mysqli_query($conexao, $consulta) or die (mysqli_error($conexao) . "<br>Erro na query: <br>". $consulta);
		  
          if (mysqli_num_rows($resultado) > 0) {
            while($registro[] = mysqli_fetch_assoc($resultado)){
            }
				
            //echo json_encode ($registro);
            
            $json = json_encode ($registro);
          }
          
          $dados = array(
            'dados' => $json
          );

          $iniciar = curl_init('http://localhost/saudesabor/2.php');
          
          
                                                                      
          curl_setopt($iniciar, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
          curl_setopt($iniciar, CURLOPT_POSTFIELDS, $dados);                                                                  
          curl_setopt($iniciar, CURLOPT_RETURNTRANSFER, true);                                                                      
         /*
          curl_setopt($iniciar, CURLOPT_HTTPHEADER, array(                                                                          
              'Content-Type: application/json',                                                                                
              'Content-Length: ' . strlen($json))                                                                       
          );                                                                                                                   

         */                                                                                                                               
          $result = curl_exec($iniciar);

          
          echo "<pre>";
          echo $result;
          echo "<pre>";
          

          $result = curl_close($iniciar);
          

          
?>