0

我正在尝试为我的 MySQL 数据库中的多个 SteamID 生成一个 HTML 表。我的数据库如下所示:

id | steamid64 | xenforo_username | xenforo_userid

 /*
  * Accountlist Query
  */
  $list = $db->query('SELECT * FROM steamlist ORDER BY id DESC');
  $list = $list->fetch_assoc();

  /*
  * Parse Query Values into Strings
  */
  $steamid = $list['steamid64'];
  $xfUsername = $list['xf_username'];
  $xfUserid = $list['xf_userid'];

  /*
  * Create array for the list
  */
  $steamlist = array( array("Forum Username | "=>$xfUsername, "Steam Username | "=>$steamapi->personaname, "SteamID | "=>$steamid, "Last Logout | "=>$steamapi->lastlogoff, "Onlinestatus"=>$steamapi->personastate)
              );

  /*
  * API URL
  */
    $api_url=file_get_contents("https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?key=$api_key&format=json&steamids=$steamid");
    $api_url = json_decode($api_url);

  /*
  * Parse API URL into variable
  */
  $steamapi = $api_url->response->players[0];

我相信我需要一个 foreach 函数来从 SteamAPI 获取存储在我的数据库中的所有 SteamID 的信息。有人可以帮我吗?

4

1 回答 1

0
<table>
<thead>
    <tr>
        <th>STEAMID</th>
        <th>USER NAME</th>
        <th>USER ID</th>
    </tr>
</thead>
<tbody>
    <!--Use a while loop to make a table row for every DB row-->
    <?php while( $row = $list->fetch()) : ?>
    <tr>
        <!--Each table column is echoed in to a td cell-->
        <td><?php echo $row['steamid64']; ?></td>
        <td><?php echo $row['xf_username']; ?></td>
        <td><?php echo $row['xf_userid']; ?></td>
    </tr>
    <?php endwhile ?>
</tbody>

于 2018-01-29T12:00:55.117 回答