0

I have problem with displaying photo from database on the page. I made a path in database column image_src = "../GameForest/gamephoto/gta5.jpg". And path is correct I checked it several times.

//This is a class that displaying all the data from the database

<?php
    class Game extends Dbh {

        public function gameDiv() {
            $id = $_GET['id'];
            $stmt = $this->connect()->query("SELECT g.game_id, g.game_name, g.image_src, g.genre_id, g.developer_id, g.release_date, g.platfrom_id, g.game_price,  g.game_description, g.processor, g.graphic, g.ram\n" . "FROM game AS g\n" . "LEFT JOIN genre AS z\n" . "ON g.genre_id = z.id WHERE game_id = '$id'");
            while ($row = $stmt->fetch()) {

                echo "<div class='gameName'><h2>" . $row['game_name'] . "</h2></div>";

                echo "<div class='buying'><p>" . $row['game_price'] . "&euro;</p><a href='bought.php'><button>Buy Game</button></a></div>";


//This next echo is for displaying photo from database:
                echo "<div class='gamePhoto'><img>" . $row['image_src'] . "</img></div>";

                echo "<div class='gameGenre'><b>Genre: </b><p>" . $row['genre_id'] . "</p></div>";

                echo "<div class='gameDeveloper'><b>Created by: </b><p>" . $row['developer_id'] . "</p></div>";

                echo "<div class='gamePlatform'><b>Platform: </b><p>" . $row['platfrom_id'] . "</p></div>";

                echo "<div class='gameRdate'><b>Release date: </b><p>" . $row['release_date'] . "</p></div>";

                echo "<div class='gameDescription'><b>Description: </b><p>" . $row['game_description'] . "</p></div>";

                echo "<div class='sysRequirements'><p>Recommended System Requirements:</p><b>Processor:</b><p>" . $row['processor'] . "</p>" . "  Heading <b>Graphic:</b><p>" . $row['graphic'] . "</p>" . " <b>RAM:</b><p>" . $row['ram'] . "</p>";
            }
        }
}

**//This is instance for previous class:**
<?php
    #istance for printing information about a Game
    $game = new Game;
    echo $game->gameDiv();
?>

**//This is CSS code of that photo:**

.gamePhoto {
        margin: 10px 0 20px 10%;
        width: 200px;
        height: 400px;
        float: left;
    }

    .gamePhoto img {
        width: 500px;
        height: 600px;    
    }

?>

I expect that there is a picture from database but I get only a gray frame where the image should actually be below that it writes "../GameForest/gamephoto/gta5.jpg" (the path I wrote in the base). The rest of the database data are displayed normally it's just a problem with images. On the other page (and other class) the same picture from the same database is normally displayed and I have no problem.

1
  • if you wanna show an image you have to do it like this <img src='path'/> and replace with your path. but you do it wrong Commented Jul 11, 2019 at 0:51

2 Answers 2

2

img is inline block,use it like <img src="" />

Sign up to request clarification or add additional context in comments.

Comments

1

Change this

<img>" . $row['image_src'] . "</img>

to this

<img src=" . $row['image_src'] . ">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.