[PHP] Need help with showing images from database

Hi guys, I have a little problem with showing images from database. I’m using this code, but it only shows one image.

[php]<?php
$con = mysqli_connect($host, $username, $password , $database)
or die(‘Error connecting to MySQL server.’);
$query = "SELECT * FROM cms_news";
$data = mysqli_query($con, $query);
$row = mysqli_fetch_array($data);

echo ’

Latest news






<a href="/hotel?room=’.$row[“room_id”].’" class=“news-header__link news-header__banner”>

<img src="’.$row[“image”].’" alt="’.$row[“image”].’" class=“news-header__image news-header__image–featured”>
<img src="’.$row[“thumbnail”].’" alt="’.$row[“thumbnail”].’" class=“news-header__image news-header__image–thumbnail”>


<a href="/hotel?room=’.$row[“room_id”].’" class=“news-header__link news-header__wrapper”>

‘.$row[“title”].’




‘.$row[“description”].’



'; ?>[/php]

You need a loop of you want to display multiple.

I have fixed it… forgot to click on “topic solved”… Can you help me with how to float 2 images next to each other per line?

Depending on how you are displaying them, make the width of each element something like, 40%

Sponsor our Newsletter | Privacy Policy | Terms of Service