Searched for the solution- found nothing. Maybe I used the wrong terms.
I try to split the server-side operations and the html structure. So I made two different files, first the index.php
and then operation.php
.
Inside of the operation.php I made a mysqli query and fetched the content of an mysql table into different variables:
$query = "SELECT * FROM work";
if ($result = $mysqli->query($query)) {
while ($row = $result->fetch_assoc()) {
$title = $row["title"];
$desc = $row["desc"];
$id = $row["id"];
$date = $row["date"];
$time = $row["time"];
$kat = $row["kat"];
$user = $row["user"];
}
$result->free();
}
$mysqli->close();
?>
Now I tried to use this in the index.php
by including the operation.php
and using it like
<div><?php echo $title ?></div>
Everything works, but I want to loop this div and get one <div>
for every 'title' row in the database.
How is this possible?
Thanks in advance.