我通过 mySQL 制作了一个简单的查询系统,它显示了 100 条记录,我将它们提取到我的游戏中,但我对 PHP 中的代码有疑问。
我希望每行之间有 5char 空间所以我必须使用制表符空间\t\t\t\t\t
(他们我得到不同的结果:
2Char string + 5char space = 7Char
和10Char string + 5Char space = 15Char
$query = "SELECT * FROM `scores` ORDER by `score` DESC LIMIT 100";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$num_results = mysql_num_rows($result);
for($i = 0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo $i+1 . "-" . "\t\t Name: " .$row['name'] . "\t\t\t\t Device: " . $row['device'] . "\n \t\t Difficulty: " . $row['level']. "\t\t\t\t Score: " . $row['score'] . "\n\n";
}
代码输出
1- Name: James Device: HTC OneX
Difficulty: Hard Score: 5760
2- Name: Erika_S Device: PC
Difficulty: Normal Score: 13780
...
我想要的输出
1- Name: James Device: HTC OneX
Difficulty: Hard Score: 5760
2- Name: Erika_S Device: PC
Difficulty: Normal Score: 13780
...