Divergent Results When Filtering API Response

0

Edit: I was able to get him to create a single tab-pane, but now he is not filtering the games according to the league as you can see in the image below, he is printing everyone! I edited the code ...

IhaveawebsiteinWordpressandI'mconsumingaWebService,Icreatedafunctiontofilterthechampionshipsbasedonsomeinformation:

Sex:M
Modality:2
Category:4

Ifallaretrue,itreturnsthenameofitschampionshipandprintsonthescreenwithina<div>data-togglebootstrap.

Withinthistoggle,anotherfunctioncomparesthevaluesbelowintotwodifferentURLs.

$api_results['championship]
$api_campeonatos['code']

Ifthesevaluesareequal,itprintsthechampionshipgameswiththeinformationbelow:

PrincipalxVisitor

Thefunctionworks,thebigproblemisthatitisnotonlypullingtheinformationfromtheabove-mentionedchampionships,butallofthem,andthetab-pane%heiscreatingoneforeachgame,butthecorrectonewouldbeforhimtocreatejustonetabwiththechampionshipid,andallthegameswiththatidwouldbeinsertedinatableformatinsideit.

Itriedtousetheforeachafteropeningthedivandalsoanarray_push,butasitismyfirsttimewithWebServiceconsumptionIamnotsucceeding,couldanyonehelpme?

ReturnsthevaluesandcomparesSEX,MODEANDCATEGORY:

<?php$api_campeonatos='https://sportsmanager.com.br/api/[email protected]&token=SXLSO8342HSDE78623GVS7234GNMSKL&ano=2018&status=A';$campeonatos=wp_remote_get($api_campeonatos);$campeonatos_data=json_decode(wp_remote_retrieve_body($campeonatos),true);$retorno_campeonatos=array();//<-mudarparaarrayif($campeonatos_data){foreach($campeonatos_dataas$row){if(!is_array($row)){//$retorno=$retorno.'<td>'.$row.'</td>';}else{if($row['sexo']=='M'&&$row['modalidade']==2&&$row['categoria']==4){$retorno_campeonatos[]=array('valor'=>'<td>'.$row['nome'].'</td>','id'=>$row['codigo']);//<---adiciona}}}}?>

Printsthenameoftheleagueinalist-group:

<script>$(function(){varhtml='';varhtml2='';<?phpforeach($retorno_campeonatosas$valor){?>html+='<aclass="list-group-item list-group-item-action" data-toggle="list" href="#bloco-<?php echo $valor['id'];?>" role="tab"><?php echo $valor['valor'];?></a>';

        html2 += '<div class="tab-pane" id="bloco-<?php echo $valor['id'];?>" role="tabpanel"><div id="cont-<?php echo $valor['id'];?>"></div></div>';

    <?php } ?>

    $('#myList').html(html);

    $('#tabList').html(html2);

});

</script>

<div class="container">
    <div class="row">   
        <div id="contents">
            <div class="list-group" id="myList" role="tablist">
            </div>

            <div id="tabList" class="tab-content">
            </div>
        </div>
    </div>
</div>

Compare the $ api_results

asked by anonymous 01.08.2018 / 14:05

0 answers