Jump to content

veks21

New Members
  • Posts

    1
  • Joined

  • Last visited

veks21's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello. I want to display all photos from the database. The problem is that it displays nothing. I added a foreach loop in html but further it not display. I'am beginner, I hope someone help me where I make mistake. I care about separation logic from view. class photo_display { private $database; private $userData; public function __construct($database) { $this->database = $database; } public function display() { $query = $this->database->connect()->prepare("SELECT photo FROM photo"); $query->execute(); if ($query->rowcount()) { $row = $query->fetchAll(); } $this->userData = $row; } public function display_Photos(string $colName) { return (isset($this->userData[$colName])) ? $this->userData[$colName] : []; } } <div class='container-fluid bg-dark' id='profil'> <div class='row'> <div class=" col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 order-5 order-12 order-6 order-md-4"> <div class="row" id="margin"> <div class="col-xl-12 d-flex justify-content-center" id="test"> <?php foreach ($photo_display->display_Photos('photo') as $value) { ?> <img src ="<?php echo var_dump($value) ?>" />; <?php } ?> </div> </div> </div>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.