我是这种语言的新手,我的问题如下。 所以,我有这段代码......
<?php
echo "<table style='border: solid 1px black;'>";
echo "<tr><th><font color='green'><center>Username</th><th><font color='green'><center>Total EXP</th><th><font color='green'><center>Online Time</th></tr>";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "<td style='width:100px;border:1px solid black;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
}
$servername = "localhost";
$username = "root";
$password = "123";
$dbname = "hiscores";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT username, overall_xp, onlinetime FROM hs_users ORDER BY overall_xp DESC LIMIT 0, 10");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
echo "$v";
}
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
echo "</table>";
?>
我想要居中,并将结果设为白色。我尝试了多种方式,我仍然无法弄清楚如何做到这一点。有人可以帮助我吗? 我已经尝试在这部分添加字体标签和内容
echo“$ v”;
无。结果总是像这样
答案 0 :(得分:0)
似乎可能有些外部文件正在更改CSS。您可以尝试!important
每种样式,如:
echo "<div style='color:#ffffff !important;text-align:center !important">$v</div>";
如果您在下一行中的每一行都使用<div>
,则可以使用<span>