• 30-12-2020, 13:55:51
    #1
    Merhabalar gametracker ı biliyorsunuzdur oradan api ile serverdaki anlık oyuncuların isimlerini vs. herşeyi çekebiliyorum bot yardımı ile fakat şöyle bir sorunum var oyuncuları listelemek istediğimde 1 tane gözüküyor foreach eklediğimde hata alıyorum bu kodlara ne eklemeliyim?

    Kodlar:
    <?php
    setlocale(LC_ALL, 'tr_TR.UTF-8');
    $url = "http://api.gametracker.rs/demo/json/server_info/95.173.173.9:27015";
     $client = curl_init($url);curl_setopt($client,CURLOPT_RETURNTRANSFER,true);
    $response = curl_exec($client); 
    $sonuc = json_decode($response); 
    $oyuncu= $sonuc->players_list[0]->player->name;
    $skor= $sonuc->players_list[0]->player->score;
    $sure= $sonuc->players_list[0]->player->time; ?>
    <html>
    <head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">    
    </head>    
    <body>        
    <br>
    <br>
    <table id="tablePreview" class="table">        
    <thead>    
    <tr>
    <th>Oyuncular</th>      
    <th>Skor</th>      
    <th>Süre</th>   
     </tr>  
    </thead>  
    <tbody>    
    <tr>      
    <td><?php echo $oyuncu;?></td>      
    <td><?php echo $skor;?></td>      
    <td><?php echo $sure;?></td>     
     </tr>     
    </tbody>
    </table>    
    </body>
    </html>
  • 30-12-2020, 14:06:11
    #2
    acil yardım edebilecek yokmu?
  • 30-12-2020, 14:31:41
    #3
    Aşağıdaki gibi sorunu çözdüm.
    <html>
    <head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">    
    </head>    
    <body>        
    <br><br>        
    <?php   $datas = json_decode(file_get_contents("http://api.gametracker.rs/demo/json/server_info/95.173.173.9:27015"));   
    $datas = $datas->players_list;
    ?>
    <table id="tablePreview" class="table">       
     <thead>    
    <tr>
          <th>Oyuncular</th>
          <th>Skor</th>
          <th>Süre</th>    
    </tr> 
     </thead>  
    <tbody>    
    <?php            foreach ($datas as $data) {         ?>   
     <tr>
          <td><?php echo $data->player->name;?></td>
          <td><?php echo $data->player->score;;?></td>
          <td><?php echo $data->player->score;;?></td>     
    <?php            }          ?>    
    </tr>     
    </tbody>
    </table>    
    </body>
    </html>