Php 从MySQL中回显并为文本添加颜色
我有一张表格来更新我们学校的房间状况。 该表单的状态为:就绪、工作、计划和未就绪 我在文件中的回显代码为:Php 从MySQL中回显并为文本添加颜色,php,html,css,Php,Html,Css,我有一张表格来更新我们学校的房间状况。 该表单的状态为:就绪、工作、计划和未就绪 我在文件中的回显代码为: <?php $mysqli = new mysqli("localhost", "root", "", "angular"); $result = $mysqli->query("SELECT * FROM c246 ORDER BY id DESC LIMIT 2"); while($row = mysqli_fetch_
<?php
$mysqli = new mysqli("localhost", "root", "", "angular");
$result = $mysqli->query("SELECT * FROM c246 ORDER BY id DESC LIMIT 2");
while($row = mysqli_fetch_array($result)) {
echo "<div class='room_status_info'>";
echo "<h3 class='room_numer'><b class='status_info'>Romnummer:</b> " . htmlentities($row['roomnumber']) . "</h3>";
echo "<br>";
echo "<p class='room_status'> <b class='status_info'>Status:</b> " . htmlentities($row['status']) . "</p>";
echo "<br>";
echo "<p class='time_updated'> <b class='status_info'>Oppdatert:</b> " . htmlentities($row['updated']) . "</p>";
echo "<br>";
echo "<p class='informasjon_rom'> <b class='status_info'>Informasjon:</b> " . htmlentities($row['information']) . "</p>";
echo "<br>";
echo "<p class='updated_by'> <b class='status_info'>Oppdatert av:</b> " . htmlentities($row['updated_by']) . "</p>";
echo "</div>";
}
?>
如果我正确解释了您的问题,您希望显示数据库中的彩色输出,以及您之前定义的颜色
像这样的东西就行了
echo "<p class='room_status'> <b class='status_info' style='color: #'. $row['colorcode']: .' >Status:</b> " . htmlentities($row['status']) . "</p>";
echo”如果我正确解释了您的问题,您希望显示数据库中的彩色输出,以及您之前定义的颜色
像这样的东西就行了
echo "<p class='room_status'> <b class='status_info' style='color: #'. $row['colorcode']: .' >Status:</b> " . htmlentities($row['status']) . "</p>";
echo”状态:
添加以下内容:
<b class='status_info' style='color: htmlentities($row['colorcode'])'>Status:</b>
状态:
状态:
添加以下内容:
<b class='status_info' style='color: htmlentities($row['colorcode'])'>Status:</b>
状态:
在SQL中,colorcode
的确切位置在哪里?颜色代码在哪里?它来自数据库或者你有风格的类?我在我的数据库中有它。在你的SQL中,colorcode
确切地存在于哪里?你的颜色代码在哪里?它来自数据库,或者您有样式中的类?我的数据库中有它。文本状态:不应该有颜色,但后面只有$行。htmlentities($row['status'])这应该有颜色,而不是:status:如果您理解:)和echo“刚刚完成了您在这里写的操作,但随后我得到了一个错误::语法错误,意外的“”(T\u封装的_和_空格),需要标识符(T\u字符串)或变量(T\u变量)或数字(T\u NUM\u字符串)这是一个回声“
“.htmlentities($row['status'])。”
“您的颜色代码是十六进制值,对吗?如果不是这样,请调整代码。当我编写代码时,文本状态:不会显示。只有htmlentities($row['status'])显示,但现在是颜色。文本状态:不应该有颜色,但后面只有$row。htmlentities($row['status']))这应该是彩色的,而不是:status:如果您理解:)和echo“只是按照您在这里写的做了,但是我得到了一个错误::语法错误,意外的“”(T_封装的_和_空格),应该是标识符(T_字符串)或变量(T_变量)或数字(T_NUM_字符串),这是echo的错“
“.htmlentities($row['status'])。”
“您的颜色代码是十六进制值,对吗?如果不是这样,请调整代码。当我编写代码时,文本状态:不会显示。只有htmlentities($row['status'])显示,但现在显示颜色。