我在 <?php endwhile; ?>
上收到错误线。
错误:
Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE);
代码:
$result = mysqli_query($connect,"SELECT* FROM contacts");
?>
<table width="800" cellpadding="10" cellspacing="5" border="2">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Contact No</th>
<th>Email</th>
</tr>
<?php while ($row = mysqli_fetch_array($result)); ?>
<tr>
<td><?php echo $row['first_name']; ?></td>
<td><?php echo $row['last_name']; ?></td>
<td><?php echo $row['contact_no']; ?></td>
<td><?php echo $row['email']; ?></td>
</tr>
<?php endwhile; ?>
</table>
表中没有显示任何记录。该页面仅显示错误。
最佳答案
如果你想使用endwhile;
,你应该在while
的条件后面加上冒号(:
),而不是分号(;
):
<?php while ($row = mysqli_fetch_array($result)): ?>
<!-- Here --------------------------------------^ >
关于php - 我的 PHP 电话簿 CRUD 项目出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37226436/