我在顯示我的帖子時出現問題。Prolem with for loop功能
運行:
- Apache的版本。 。2.2.19(Unix的)
- PHP版本5.2 *
錯誤顯示: 「解析錯誤:語法錯誤,意想不到的T_STRING的index.php上線22」
下面是PHP腳本:
<?php
include('includes/connect_to_mysql.php');
?>
<?php include_once('functions/functions.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>magazin</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
$posts = get_posts();
?>
<?php
foreach($posts as $post){
<article>
<div class="three columns alpha thumbnail">
<figure><img src="images/<?php echo $post[`posts_id`]; ?>.jpg" alt="<?php echo $post[`posts_title`]; ?>" /></figure>
</div><!--three-->
<div class="seven columns omega">
<h2><a href = "single.php?id=<?php echo $post[`posts_id`]; ?>"><?php echo $post[`posts_title`]; ?></a></h2>
<p class="meta">Posted by<a href = "<?php echo $post[`posts_id`]; ?>"><?php echo $post[`posts_user`]; ?><?php echo $total_comments; ?></a></p>
<p><?php echo $post[`contents`]; ?></p>
</div><!--seven--><hr/>
</article><!--blog post-->
}
<?php
}
?>
</body>
</html>
你有沒有語法錯誤? – aldanux
不能先看看你的代碼,然後問這樣的問題? –