I am building this website where people can add events to a calendar. I created a form that puts data into my database, but now I want to know the magic about how to get the data out of the database! Since I just started this project as a school assignment, I have a little struggle with mixing PHP and HTML. I hope I have done right;
<?php
include("template.php");
$servername = "servername";
$username = "username";
$password = "password";
$dbname = "dbname";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<body>
<div class="outer">
<h2> Beheerderspagina </h2>
<hr>
<?php
$sql = "SELECT name, organisator, begin, end, location, province, price, sort, website, description FROM events";
$result = $conn->query($sql);
if ($result->num_rows > 0);
while($row = $result->fetch_assoc());
echo <<<HTML
<div class="add">
<div class="block">
<div class="photo">
<img src="geen_foto_beschikbaar.jpg" width="250px" height="250px">
</div>
<div class="text">
<div class="links">
<p>
Naam:<br>Organisator:<br>Datum:<br>Locatie:<br>Provincie/land:<br>Gemiddelde prijs:<br>Genre:<br>Website:<br>Omschrijving </p>
</div>
<div class="rechts">
HTML;
echo "<br>".$row["name"]."<br>".$row["organisator"]. "<br>". $row["begin"]. " tot ". $row["end"]. "<br>". $row["location"]. "<br>". $row["province"]. "<br>". $row["price"]. "<br>". $row["sort"]. "<br>". $row["website"]. "<br>". $row["description"]. "<br>";
echo <<<HTML
</div>
</div>
</div>
</div>
HTML;
?>
So this is the code, but it isn't working. The problem is, it isn't displaying my data. The word 'tot' is displayed, but the rest is just empty. How can while loop over the data and display it per row in div's?