1

I have made a database and connected it properly. I am trying to display the database contents to be side by side. I have tried to create a div but everything is jumbled up. The items are floating left but are not showing up side by side.

<html>
<head>

<style>

.menu{
    float:left;
}

p{
    text-align:left;
    float:left;
    inline-size:300px;
    overflow:hidden;

}
</style>

</head>
<body>
    <main>
        <section>

<h3>Inventory</h3>

<?php include 'db.php';

$ID = $_GET['ID'];
$query = "SELECT * FROM inventory ORDER BY ID";

/* Try to query the database */
if ($result = $mysqli->query($query)) {
   // Don't do anything if successful

}
else
{
    echo "Sorry, an item with the ID of $ID cannot be found " . mysql_error()."<br>";
}

while ($result_ar = mysqli_fetch_assoc($result)) {
    //Display food image and image source
    $image = $result_ar['Image'];
     echo "<div class = 'menu'>" . $result_ar['Image_Source'] . "<br>".
    "<IMG src= 'images/$image' style = height:200px; width:300px;>". "</div>";
    //Display name and description
      echo "<p>".$result_ar['Name'] . "<br>"
     . $result_ar['Description'] ."</p>";

}

$mysqli->close();
?>
        </section>
    </main>

</body>
</html> 
Stu
  • 30,392
  • 6
  • 14
  • 33
  • You have an error. [`mysql_error()`](https://www.php.net/manual/en/function.mysql-error.php) worked only for the old API. Please consider switching error mode on instead. [How to get the error message in MySQLi?](https://stackoverflow.com/a/22662582/1839439) – Dharman Mar 08 '22 at 19:42

0 Answers0