你好我正在寻找创建一个基本的照片库网站一切工作得到它输出用户和图像像instagram主页但现在我试图输出每个用户一次和4上传他们的图像,如果用户上传的图像超过4只输出4,如果小于4则输出全部。
它只输出名称..但我想输出每个用户和他们上传的4个图像..任何建议?
$result = mysqli_query($con, "SELECT * FROM litrato_db JOIN users ON litrato_db.author_id = users.user_id GROUP BY user_id ") or die (mysqli_error());
while ($row = mysqli_fetch_array($result)) {
$userName = $row['user_name'];
echo $userName;
$result2 = mysqli_query($con, "SELECT * FROM litrato_db JOIN users ON litrato_db.image_id = users.user_id GROUP BY user_id") or die (mysqli_error());
while ($row = mysqli_fetch_array($result2)) {
$imageTitle = $row['title'];
$fileName = $row['filename'];
$imageDesc = $row['caption'];
$imageTimeDate = $row['timedate'];
$imageId = $row['image_id'];
// $userName = $row['user_name'];
echo "<div class=\"posting\">";
echo "<div class=\"thePoster\">";
echo "<div class=\"thePostDate\">";
echo "$imageTimeDate";
echo "</div>";
echo "</div>";
echo "<div class=\"thePost\">";
echo "<p>$imageTitle</p>";
echo "<a href =\"admin/detail.php?id=$imageId\">";
echo "<img src=\"thumbs/$fileName\"/>";
echo "</a>";
echo "</div>";
echo "</div>";
}
}