我如何从mysql打印值,我在表中有一些主题,我需要将它们作为注释打印在同一行中。
但是代码在做重复项,我也在表中插入了注释。
$sql = "SELECT response.date,response.session, board.id as idboard, Jmeno,Koment,Text, Nazev as 'Nazev', Prezdivka as 'Prezdivka', board.Datum as 'Datel' FROM `board` left join users on board.ID_user=users.ID join response where response.ID_board=board.ID
";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<div class='card'>
<div class='card-header' style='color:red;background-color:lightblue;'>" . $row["Nazev"]. " <a class='float-right'>Uživatel: " . $row["Prezdivka"]. " Datum: " . $row["Datel"]. "</a></div>
<div class='card-body' style='background-color:lightgrey;'>" . $row["Text"]. "</div>
</div>
<a href='prikazy/detail.php?id='>Odpovědi<a><br> " . $row["Koment"]. " <a style='color:pink;'>" . $row["session"]. " " . $row["date"]. " </a>
<form method='post' action='index.php'> <input type='hidden' name='idboard' value=" . $row["idboard"]. " > <input type='text' class='form-control float-right' placeholder='Zadejte nový komentář...' name='komentar'> <br>
<BR><button type='submit' class='btn btn-info float-right' name='komentovat'>Komentovat</button>
</form><br><hr>";
}
} else {
echo "0 výsledků v DB";
}