我正在尝试为我的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的信息。有人能帮我一下吗?
发布于 2018-01-29 20:00:55
<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>
https://stackoverflow.com/questions/48500365
复制相似问题