我正在尝试查询MySQL数据库,并在PHP网页上显示结果,如下,
x1c 0d1x但是我得到错误解析错误:语法错误,在C:\wamp64\www\webform\display-data.php的第5行出现意外的'position'(T_STRING)。以下是我的PHP代码
<?php
$mysqli = mysqli_connect('localhost','staff','staff','webform');
$query ="SELECT position FROM entries";
$result = $mysqli->query($query);
if($result->num_rows> 0){
$options= mysqli_fetch_all($result, MYSQLI_ASSOC);
}
<?php
<?php
include("dbconfig.php");
include("fetch-data.php);
?>
<select name="position">
<option>Select staff</option>
<?php
foreach ($options as $option) {
?>
<option><?php echo $option['position']; ?> </option>
<?php
}
?>
</select>
1条答案
按热度按时间sgtfey8w1#
代码中缺少引号。请将
include("fetch-data.php);
更改为include("fetch-data.php");