只能显示1张图片。如果用户有超过1个图像如何显示它

时间:2016-05-26 02:49:34

标签: php mysql

在我的程序中,用户登录并可以上传图像。用户可以查看他的所有图像并将其删除。

问题是我只能显示1张图片。如果用户有超过1个图像如何显示它。

Display.php的

<?php
session_start();
require_once 'class.user.php';
$user_home = new USER();
$reg_user = new USER();
$stmt = $user_home->runQuery("SELECT * FROM bike_tbl WHERE userID=:uid");
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);

$userID=$row['userID'];
echo $userID;
if(isset($_POST['btn-update']))
{
    $status = $_POST['status'];
    $remarks = $_POST['remarks'];


    if($reg_user->updateBike($status,$remarks,$userID))
    {
        echo "good";


    }
    else {
        echo "bad";


    }
}
?>
<form action="" method="post">
<table class="table table-bordered">
            <thead>
                <tr>
                    <th>Image</th>
                    <th>File Name</th>
                    <th>Serial Number</th>
                    <th>Status</th>
                    <th>Remarks</th>
                </tr>
            </thead>

            <?php while ($row[image])?>
            <tbody>
                <tr>
                    <td><img src="uploads/<?php echo $row['file'] ?>" height="100" width="100"></td>
                    <td><?php echo $row['file'] ?></td>
                    <th><?php echo $row['serialNumber'] ?></th>
                    <td><select name="status">
                            <option value="In use">In use</option>
                            <option value=Deleted>Deleted</option>

                    </select>
                    </td>
                    <td><input type="text" name="remarks" /></td>

                </tr>

                </tbody>

</table>
<button class="btn btn-large btn-primary" type="submit" name="btn-update">Update</button>
</form>

class.user.php

public function updateBike($status,$remarks,$userID)
    {
        try
        {

//          echo $status;
//          echo$remarks;
//          echo$userID;
//          echo "UPDATE bike_tbl SET status=$status,remarks=$remarks WHERE userID=$userID:";


        $stmt = $this->conn->prepare("UPDATE bike_tbl SET status=:status,remarks=:remarks WHERE userID=:userID");

        $stmt->bindparam(":status",$status);
        $stmt->bindparam(":remarks",$remarks);
        $stmt->bindparam(":userID",$userID);

            $stmt->execute();

            return $stmt;
        }
        catch(PDOException $ex)
        {
            echo $ex->getMessage();
        }
    }

0 个答案:

没有答案