我在以下结构/逻辑上苦苦挣扎……该项目是关于如何在 php 和 mysql 上建立联盟,每个玩家都必须互相对抗
我想生成一个像这样的(动态)表:
<table border="1">
<tr>
<td>--</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>1</td>
<td>--</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
</tr>
<tr>
<td>2</td>
<td>--</td>
<td>--</td>
<td>x</td>
<td>x</td>
<td>x</td>
<td>x</td>
</tr>
<tr>
<td>3</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>x</td>
<td>x</td>
<td>x</td>
</tr>
<tr>
<td>4</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>x</td>
<td>x</td>
</tr>
<tr>
<td>5</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>x</td>
</tr>
<tr>
<td>6</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
<td>--</td>
</tr>
</table>
每个数字都是一个昵称,所以这最终是如何显示统计数据
现在我的东西到目前为止:
$get_player = mysql_query("SELECT nickname, id FROM player");
$get_player_score = mysql_query("select
player_id, game1, game2, game3
from
1on1_matches_scores
where
1on1_matches_id = (select
id
from
1on1_matches
where
league_id = (select
id
from
league
where
league_type_id = (select
id
from
league_type
where
id = 1)
and season_id = (select
id
from
season
where
id = 1))
limit 1)");
while ($row = mysql_fetch_array($get_player))
$results[$row[nickname]][] = $row[id];
while ($row = mysql_fetch_array($get_player_score))
$data[$row[player_id]][] = $row[game3];
echo "<table border='1'><tr>";
echo "<td>--</td>";
foreach ($results as $key => $value)
echo "<td>$key</td>";
echo "</tr>";
foreach ($results as $key => $value) {
echo "<tr><td>$key</td>";
foreach ($data as $key => $value) :
foreach ($value as $cell_value)
echo "<td>Punkte: $cell_value</td>";
endforeach;
echo "</tr>";
}
好吧,我如何从玩家 1 和玩家 2 获取特定值(匹配结果)到确切的 td 中?