【发布时间】:2018-04-16 04:04:45
【问题描述】:
我之前在循环和 if 语句中使用过 HTML 没有问题。但现在我卡住了。
我有一个 while 循环和一个 if 语句,如下所示:
while ($row = mysqli_fetch_array($result)) {
$gcode = $row ['code'];
$gname = $row ['gname'];
$firstletter = substr($gname, 0, 1);
if ($gid == $firstletter) {?><div>some html</div><?php}
}
它只是行不通。没有警告信息或任何东西,只是一个空白页。但是,如果我用这样的 echo 替换 HTML,它就可以工作。
while ($row = mysqli_fetch_array($result)) {
$gcode = $row ['code'];
$gname = $row ['gname'];
$firstletter = substr($gname, 0, 1);
if ($gid == $firstletter) {echo "some html";}
}
谁能给点建议。谢谢!
【问题讨论】:
-
$gid定义在哪里? -
错误在
some html我想。但正如你没有表现出来的那样 - 没有人可以提供帮助。 -
如果这不是完整的代码,其他答案也无济于事。尝试回显'lalal也许你的元素隐藏在页面上或其他东西'
标签: php html if-statement while-loop