我需要连接两张桌子......请帮帮我!
<?php
$tabela = mysql_query("SELECT * FROM rankpvp ORDER BY ratio DESC LIMIT 1");
while($pvp = mysql_fetch_assoc($tabela)){
$classe = mysql_query("SELECT * FROM char WHERE char_id = '".$pvp['char_id']."'");
echo ' classe: '.$classe['class'].'<br> Nome: '.$pvp['name'].'<br> Pontos: '.$pvp['ratio'].'<br> Kills: '.$pvp['kills'].'<br> '; } ?>
答案 0 :(得分:1)
这可以通过一个查询
完成SELECT * FROM `char` WHERE char_id = (SELECT char_id FROM rankpvp ORDER BY ratio DESC LIMIT 1)
请注意,char是一个保留字,所以它必须包含在后面的刻度中。也许这是您遇到的实际问题(语法错误)而不是您的while循环问题。然而,一个查询是正确的方式