【发布时间】:2013-03-04 22:07:36
【问题描述】:
我正在使用来自两个查询的数据创建一个表,并尝试将它们连接到一个表中。 尝试使用类似的东西:
$counter = 1;
echo '<table border="0" cellpadding="0" cellspacing="3"><tr>
<td width="10%">Miejsce</td>
<td width="25%">Nick</td>
<td width="20%">SteamID</td>
<td width="20%">Punkty</td>
</tr>';
while($row = mysql_fetch_array($skill_b) AND $row2 = mysql_fetch_array($sid_b))
{
echo '<tr class="select">';
echo '<td>'.$counter.'</td>';
echo '<td><center>'.$row['lastName'].'</center></td>';
echo '<td><center>'.$row2['uniqueId'].'</center></td>';
echo '<td><center>'.$row['skill'].'</center></td>';
echo '</tr>
$counter++;
}
echo '</table>';
和
$counter = 1;
echo '<table border="0" cellpadding="0" cellspacing="3"><tr>
<td width="10%">Miejsce</td>
<td width="25%">Nick</td>
<td width="20%">SteamID</td>
<td width="20%">Punkty</td>
</tr>';
echo '<tr class="select">';
echo '<td>'.$counter.'</td>';
while($row = mysql_fetch_array($skill_b))
{
echo '<td>'.$row['lastName'].'</td>';
}
while($row2 = mysql_fetch_array($sid_b))
{
echo '<td>'.$row2['uniqueId'].'</td>';
}
while($row3 = mysql_fetch_array($skill_b))
{
echo '<td>'.$row3['skill'].'</td>';
}
$counter++;
echo '</table>';
第二个几乎可以工作,虽然它使整个表崩溃,所以我看不到所有结果。
如果其中有可以更改的内容,查询看起来像这样:
$query_skill = sprintf(
"SELECT skill, lastName
From hlstats_Players
ORDER BY skill DESC
LIMIT 10");
$skill_b = mysql_query($query_skill);
$skill = mysql_result( $skill_b, -1 );
$query_sid = sprintf(
"SELECT uniqueId
From hlstats_PlayerUniqueIds
WHERE playerId='$pid_b'"
);
$sid_b = mysql_query($query_sid);
$sid = mysql_result( $sid_b, 0 );
【问题讨论】:
标签: php mysql while-loop html-table