<?php
header('Content-type: text/json');
require "/home/desenvwor/public_html/videos/config/config.php";
$conecta = new mysqli(BD_HOST,BD_USUARIO,BD_SENHA,BD_BANCO);

$i = 1;
$sql = $conecta->query("SELECT * FROM servicos WHERE destaque = '1' ORDER BY titulo ASC");
while ($consulta = $sql->fetch_assoc()){
$evNum = 'servico_'.$i;
$servico[$evNum]['id'] = $consulta['id'];
$servico[$evNum]['titulo'] = $consulta['titulo'];
$servico[$evNum]['descricao'] = $consulta['descricao'];

$c = 1;
$sqlF = $conecta->query("SELECT * FROM imgServicos WHERE idServico = '".$consulta['id']."' ORDER BY id ASC");
while ($consultaF = $sqlF->fetch_assoc()){
$ftNum = 'foto_'.$c;
$servico[$evNum][$ftNum]['idFoto'] = $consultaF['id'];
$servico[$evNum][$ftNum]['arquivo'] = $consultaF['arquivo'];
$c = $c + 1;}

$i = $i + 1;}

$json_string = json_encode($servico);

echo $json_string;
?>