Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 回显每个成员ID的图像_Php_Mysqli - Fatal编程技术网

Php 回显每个成员ID的图像

Php 回显每个成员ID的图像,php,mysqli,Php,Mysqli,大家好,正如你们所看到的,echo将显示登录会员下载的图片。但我不知道如何创建循环,我可以显示每个会员下载的图片?数据库只有ID、MemberID和Pcuture名称。 例如,回显每个成员ID为2的图片。 我应该使用JOIN吗?您将mysqli\u fetch\u assoc放入while循环中 <?php require('includes/config.php'); include("includes/conf_proc.php"); //if not logged in redi

大家好,正如你们所看到的,echo将显示登录会员下载的图片。但我不知道如何创建循环,我可以显示每个会员下载的图片?数据库只有ID、MemberID和Pcuture名称。 例如,回显每个成员ID为2的图片。
我应该使用JOIN吗?

您将
mysqli\u fetch\u 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);
$rows = mysqli_fetch_assoc($img);
$num_row = mysqli_num_rows($img);


?>

<div class="container">

    <h2 style="margin-bottom:10px;margin-left:15px;">User account</h2>
        <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>
    </div>
    <?php 
//include header template
require('layout/footer.php'); 
?>

//包含标题模板
要求('layout/footer.php');
?>

“我应该使用JOIN吗?”–不,当然不是。联接用于将多个表中的数据联接在一起(如果有列相互交叉引用,也可以将一个表中的数据联接在一起),但这里只有一个非常简单的表。因此,您所需要的只是一个循环——即使是手册中非常基本的例子也可以向您展示它是如何工作的。Tnx为澄清伴侣!我明白了,我有很多朋友!
<?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'); 
?>