Hello! I display pictures in a table from the database.

Hello! I display pictures in a table from the database.

 I display pictures in a table from the database. If I do not use a modular window, display it as it should in each cell. But if I use a modular window, displayed only the last image in each cell . Plz  help to change the code or write function


  1. <!DOCTYPE html>
    <html lang="en">
    <head><meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="assets/control_styles.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>

    </head>
    <body>

    <?php

    class Crud
    {
    public $connect;
    private $host = 'localhost';
    private $username = 'root';
    private $password = '';
    private $database = 'registration';

    function __construct()
    {
    $this->database_connect();
    }

    public function database_connect()
    {
    $this->connect = mysqli_connect($this->host,
    $this->username, $this->password, $this->database);
    }

    public function execute_query($query)
    {
    return mysqli_query($this->connect, $query);
    }

    public function get_data_in_table($query)
    {
    $output = '';
    $result = $this->execute_query($query);
    $output .= '

    <table class="table table-bordered table-striped">
    <tr>
    <th width="5%">Week</th>
    <th width="10%">Image</th>
    <th width="10%">Draft</th>
    <th width="10%">Description</th>
    <th width="15%">Filter Name</th>
    <th width="10%">Quantity</th>
    <th width="20%">Message</th>
    <th width="10%">Update</th>
    <th width="10%">Delete</th>
    </tr>
    ;

    ';
    if(mysqli_num_rows($result) > 0)
    {
    while($row = mysqli_fetch_object($result))
    {
    $output .= '

    <tr>
    <td>'.$row->week.'</td>

    <td><img src="upload/'.$row->image.'" class="img-thumbnail"
    id="myImg" width="50" height="35" /> </td>


    <td> <button type="button" class="btn-primary"
    data-toggle="modal" style="border-radius: 3px; margin 0px"
    data-target="#picture3">
    pi
    </button>
    <div class="modal fade" id="picture3">
    <div class="modal-dialog">
    <div class="modal-content">
    <div class="modal-body">
    <img id="filter_description" src="upload/'.$row->image2.'"
    class="img-thumbnail" width="350" height="350"/>
    </div>
    </div>
    </div>
    </div>
    </td>


    <td><img src="upload/'.$row->pdf_files.'"
    class="img-thumbnail" width="50" height="35" /></td>
    <td>'.$row->first_name.'</td>
    <td>'.$row->last_name.'</td>
    <td>'.$row->message.'</td>
    <td><button type="button" name="update" id="'.$row->id.'"
    class="btn btn-success btn-xs update">Update</button></td>
    <td><button type="button" name="delete" id="'.$row->id.'"
    class="btn btn-danger btn-xs delete">Delete</button></td>
    </tr>
    ';
    }
    }
    else
    {
    $output .= '
    <tr>
    <td colspan="5" align="center">No Data Found</td>
    </tr>
    ';
    }
    $output .= '</table>';
    return $output;
    }

    function upload_file($file)
    {
    if(isset($file))
    {
    $extension = explode('.', $file['name']);
    $new_name = rand() . '.' . $extension[1];
    $destination = './upload/' . $new_name;
    move_uploaded_file($file['tmp_name'], $destination);
    return $new_name;
    }
    }
    }
    ?>
    </body>
    </html>