我正在尝试创建一个列出MySQL数据库中最近6个项目的页面。我使用以下代码(gen列是包含图像URL的列);
$result = mysqli_query($con,"SELECT gen,title,view FROM id
ORDER BY 'id' DESC LIMIT 5,1");
$row = mysql_fetch_array($result)
while ($row = mysql_fetch_array($result)){
echo '
<div class="row">
<div class="col-md-4 col-sm-6">
<div class="portfolio-item">
<div class="portfolio-image">
<a href="page-portfolio-item.html"><img src="i/raw' . $row['gen'] . ' alt="' . $row['title'] . '"></a>
</div>
<div class="portfolio-info-fade">
<ul>
<li class="portfolio-project-name">' . $row['title'] . '</li>
<li>Views: ' . $row['view'] . '</li>
<li class="read-more"><a href="http://minecraftimg.com/i/' . $row['gen'] . '.php" class="btn">Go!</a></li>
</ul>
</div>
</div>
</div>';
}
但是,我收到以下错误;
PHP Parse error: syntax error, unexpected 'while' (T_WHILE) in /home/...
任何帮助将不胜感激!
答案 0 :(得分:2)
缺少一个;在你的while循环之前:
$row = mysql_fetch_array($result);
答案 1 :(得分:1)
缺少分号:
$row = mysql_fetch_array($result);