-3 php
我编写了一个PHP脚本来从SQL数据库中提取数据以显示在网页上.一切似乎都很好但是当我运行脚本时它会抛出错误:
解析错误:语法错误,意外')',期待';' 在第21行的db_data.php中
第21行是我的FOR循环,我检查了循环的语法,它似乎是正确的所以我无法理解为什么它失败了.
$result = mysqli_query($con,"SELECT * igi");
echo "<table border='1'>
<tr>
<th>Ref</th>
<th>Nameame</th>
<th>Location</th>
<th>Email</th>
<th>Issue</th>
<th>Urgency</th>
</tr>";
for($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['REF'] . "</td>";
echo "<td>" . $row['NAME'] . "</td>";
echo "<td>" . $row['LOCATION'] . "</td>";
echo "<td>" . $row['EMAIL'] . "</td>";
echo "<td>" . $row['ISSUE'] . "</td>";
echo "<td>" . $row['URGENCY'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
Run Code Online (Sandbox Code Playgroud)
改变为while
<?php
// Missing FROM here vv
$result = mysqli_query($con,"SELECT * FROM igi");
echo "<table border='1'>
<tr>
<th>Ref</th>
<th>Nameame</th>
<th>Location</th>
<th>Email</th>
<th>Issue</th>
<th>Urgency</th>
</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['REF'] . "</td>";
echo "<td>" . $row['NAME'] . "</td>";
echo "<td>" . $row['LOCATION'] . "</td>";
echo "<td>" . $row['EMAIL'] . "</td>";
echo "<td>" . $row['ISSUE'] . "</td>";
echo "<td>" . $row['URGENCY'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49 次 |
| 最近记录: |