我有2表,评论和八卦。
流言有3列:ID,用户ID,八卦。
评论有4列:ID,用户ID,gossipid,评论。
我写了这个代码,使程序回声所有具体到每一个八卦婆娘和意见。
$query = 'SELECT * FROM gossips ORDER BY id DESC LIMIT 0,10';
$result = mysqli_query($cxn, $query)
or die("Couldn't execute query");
while($row = mysqli_fetch_assoc($result))
{
echo '<div class="gossip">'.$row['gossip'].'</div><form action="comment.php" method="post"><input type="hidden" name="gossipid" value="'.$row['id'].'" />';
echo '<input type="text" name="comment" placeholder="Write your comment here"/><br /><input type="submit" value="Comment" /></form><br />';
$querycomment = "SELECT * FROM comment WHERE gossipid ='{$row['id']}' ORDER BY id DESC";
$resultcomment = mysqli_query($cxn, $query)
or die("Couldn't fetch comments.");
while($comments = mysqli_fetch_assoc($resultcomment))
{
echo $comments['comment'];
}
}
此代码的输出仅呼应八卦,并且不执行所述第二while循环。 可能是什么问题呢 ?