Guest User

Untitled

a guest
Mar 21st, 2017
851
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     include("db_connect.php");
  3.    
  4.     $steamIds = [];
  5.     $usersData = [];
  6.    
  7.    
  8.     $query = "SELECT * FROM users_profiles ORDER BY `id` DESC limit 15";
  9.     $result = mysqli_query($query) or die("Request failed");
  10.     while ($row = mysqli_fetch_assoc($result)) {
  11.         $usersData[$row['steam_id']] = $row;
  12.         $steamIds = $row['steam_id']
  13.     }
  14.    
  15.    
  16.     $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . $steamauth['apikey'] . "&steamids=" , join(',', $steamIds);
  17.     $ch = curl_init();
  18.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  19.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  20.     curl_setopt($ch, CURLOPT_URL,$uuser);
  21.     $result=curl_exec($ch);
  22.     curl_close($ch);
  23.     $steamData = json_decode($result, true);
  24.    
  25.     foreach($steamData['response']['players'] as &$player) {
  26.         $usersData[$player['steamid']]['steam_avatar'] = $player['avatarfull'];
  27.         $usersData[$player['steamid']]['steam_name'] = $player['personaname'];
  28.     }
  29.    
  30.     $chunked = array_chunk($usersData, 3); 
  31.   ?>
  32.  
  33.   <table class="table table-striped table-responsive table-bordered">
  34.     <tbody>
  35.         <?php foreach($chunked as &$chunked_row): ?>
  36.             <tr>
  37.                 <?php foreach($chunked_row as &$chunked_cell): ?>
  38.                     <td>
  39.                         <center>
  40.                             <img src="<?= htmlspecialchars($chunked_cell['steam_avatar']); ?>" width="50px" height="50px"/>
  41.                             <?= htmlspecialchars($chunked_cell['steam_avatar']); ?>
  42.                         </center>
  43.                     </td>
  44.                 <?php endforeach; ?>
  45.             </tr>
  46.         <?php endforeach; ?>
  47.     <tbody>
  48.   </table>
RAW Paste Data