if(idExists($id)) {
print 'value was true';
} else {
print 'value was false';
}
大家好,你可以看到回声即将显示Loged会员下载的图片。但我不知道如何创建循环,我可以显示每个图片成员下载?所有该数据库都有ID,MemberID和Pcuture名称。 例如,回显每个具有成员ID 2的图片。 我应该使用JOIN吗?
答案 0 :(得分:1)
您将mysqli_fetch_assoc
置于while
循环中。
<?php require('includes/config.php');
include("includes/conf_proc.php");
//if not logged in redirect to login page
if(!$user->is_logged_in()){ header('Location: login.php'); }
//define page title
$title = 'Account Page';
//include header template
require('layout/header.php');
$img_query = "SELECT * FROM `images` WHERE memberID='".$_SESSION['memberID']."'";
$img = mysqli_query($conn, $img_query);
$num_row = mysqli_num_rows($img);
?>
<div class="container">
<h2 style="margin-bottom:10px;margin-left:15px;">User account</h2>
<?php
while($rows = mysqli_fetch_assoc($img))
{
?>
<div class="row" style="background-color: white;">
<div class="col-sm-6 col-md-12" style="margin-top:20px; margin-left:90px">
<?php
echo '<img src="./demo/covers/'.$rows['image'].'" />';
echo $num_row;
?>
</div>
</div>
<?php
}
?>
</div>
//include header template
require('layout/footer.php');
?>