我写了一个基本的循环在PHP中工作,我想要什么,但现在我试图添加一个链接,但无法获得正确的语法和我发现语法不起作用的例子对我而言,不断收到错误。如果任何人都可以告诉我我错误的地方,那将是惊人的。预先感谢您是否能够提供帮助!使用php链接语法错误
所引发错误的代码是
<a href=\"addcomment.php?id="'. $row['postid'] .'\">' "Add Comment" '</a>");
和完整的代码。
<?php
include("connect.php"); //connect to database
//create query
$get_messages_query = $db->prepare("
SELECT * FROM `blogposts`
ORDER BY `postid` DESC
LIMIT 5
");
//Homepage should have last 5 blog posts this will take the //last 5 entered into the database and put them into an //array
$get_messages_query->execute();
//executes query above
while($row = $get_messages_query->fetch())
{
$blog_post_history .=
'<div class="post" id="post">
<h1>'. $row['title'] .' </h1>
<h2>' . $row['author'] . '</h2>
<p>'. $row['content'] . '</p>
<a href=\"addcomment.php?id="'. $row['postid'] .'\">' "Add Comment" '</a>");
</div>';
}
// while loop that takes info from db query and puts the //information in its own div with title andauthor having a //unique heading for css as well as a p for the content of //the blog. This loop puts the information in //$blog_post_history which is called upon in the div code
//below
?>
PDO有绝对无关,与任何链接或HTML。 – 2013-05-06 05:27:57