Db db2 代碼示例到目前爲止只列出所有帖子,但只顯示一條評論? 代碼我目前只顯示一條評論?PHP while while語句中的語句?
請任何人的協助我真的需要幫助是在編碼noob,並盡我所能。謝謝你在前進
<?php
include("../db/db.php");
{
/*if(isset($_POST["TimeLine"])){*/
$queryposts = "SELECT * FROM post";
$run_query = mysqli_query($con,$queryposts);
while($row = mysqli_fetch_array($run_query)){
$post_id = $row["post_id"];
$uid = $row["user_id"];
$content = $row["content"];
$like = $row["total_like"];
$date = $row["date_created"];
$uidpic = $row["profilepic"];
$email = $row["email"];
$pImage = $row["postimage"];
$pVideo = $row["video"];
echo "<b>POST: <b/><hr />".
$content."<hr >"
;
$querycomment = "SELECT * FROM comment WHERE comment_id = $post_id";
$run_queryb = mysqli_query($con,$querycomment);
while($row = mysqli_fetch_array($run_queryb)){
$ComId = $row["comment_id"];
$Comment = $row["comment"];
$ComDate = $row["comment_date"];
$ProfilePicpost = $row["profilepic"];
echo "<b>Comment: <b/><hr />".
$Comment."<hr >"
;
}
}
}
您正在重置每個while循環中的'$ row'。對帖子和評論使用不同的行變量。 – aynber