我想改变颜色文本如果状态相等就绪,但有些事情是错误的,因为文本是风格像div。 我不知道我哪里犯错了。
if ($record['status'] == "Ready") {
echo "<div class='zlecenie' style='color:blue;'>" . $record['computer'] . "</div>";
echo "<div class='zlecenie' style='color:blue;'>" . $record['status'] . "</div>";
echo "<br/>";
} else {
echo "<div class='zlecenie' style='color:orange;'>" . $record['computer'] . "</div>";
echo "<div class='zlecenie' style='color:orange;'>" . $record['status'] . "</div>";
echo "<br/>";
}
<div id="formularz" class="zlecenie">
<form method="get" action="index.php" class="red">
<input type="hidden" name="kat" value="serwis" class="red"/>
<label>Podaj numer Telefonu <span>*</span></label>
<input name="tel" placeholder="000 000 000" required class="red">
<input style="color=green" id="submit" name="submit" type="submit" value="Sprawdź zlecenie" class="red">
</form>
</div>
您可以根据状态将颜色保存为变量$color
。 应该是这样的:
if ($record['status'] == 'Ready') {
$color = 'blue';
} else {
$color = 'orange';
}
echo "<div class='zlecenie' style='color:" . $color . ";'>" . $record['computer'] . "</div>";
echo "<div class='zlecenie' style='color:" . $color . ";'>" . $record['status'] . "</div>";
echo "<br/>";
给未来的小费。 保持代码干净。 这样读起来容易多了。 否则,稍后您或阅读您代码的人将很难理解正在发生的事情。