I want to display mysql result horizontally in a div, div is set on overflow-x : scroll
but it is not working, result is coming horizontally but it goes on the next line as the page width ends.
instead of the next line i want entire thing in single line
here is the code
PHP/Html code :
<p1>Popular</p1><div class="posterbar">
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "movie_db2";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT `poster`, `movie`FROM `movie_db2`" ;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc())
echo "<div class=\"imgc\"><a href=".$row["movie"]."><img src =" . $row["poster"]. "></a></div>";
} else {
echo "0 results";
}
$conn->close();
?>
</div>
Css :
.posterbar{
position : relative;
overflow-x: scroll;
top : 400px;
width: 85%;
height: 211px;
float: right;
z-index: 45;
background: #D8D8D8;
border: 1px solid #979797;
border-top-left-radius: 8px;
border-bottom-left-radius: 8px;
}
.imgc {
border: 1px solid white;
display: inline-flex;
max-height: 190px;
max-width: 140px;
}