我在 while 循环中有一个按钮,我想在其上使用 Bootstrap 样式。我实际上认为我可以替换我当前的 HTML 按钮代码,但我收到错误:syntax error, unexpected 'form' (T_STRING), expecting ',' or ';'
。有什么聪明的方法可以做到这一点吗?
while($row = $res->fetch_assoc()) {
echo "Id: " . $row["id"]. "<br>" .
"<button>Read More</button><br><br>";
}
这是我想在我的 while 循环中设置的按钮:
<div class="form-group">
<label class="col-md-4 control-label"></label>
<div class="col-md-4">
<button type="submit" class="btn btn-warning" >Send <span class="glyphicon glyphicon-send"></span></button>
</div>
</div>
我尝试在我的 while 循环中设置引导按钮代码,如下所示:
while($row = $res->fetch_assoc()) {
echo "Id: " . $row["id"]. "<br>" .
"
<div class="form-group">
<label class="col-md-4 control-label"></label>
<div class="col-md-4">
<button type="submit" class="btn btn-warning">Send <span class="glyphicon glyphicon-send"></span></button>
</div>
</div>
";
}
最佳答案
您需要转义放在 echo 中的 "。
while($row = $res->fetch_assoc()) {
echo "Id: " . $row["id"]. "<br>" .
"
<div class=\"form-group\">
<label class=\"col-md-4 control-label\"></label>
<div class=\"col-md-4\">
<button type=\"submit\" class=\"btn btn-warning\">Send <span class=\"glyphicon glyphicon-send\"></span></button>
</div>
</div>
";
}
关于php - 在 while 循环中回显 css 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43478203/