Help needed! I have made a comment where I need help
Code:
<!--Revising forum/index.php-->
<?php
!session_start();
$emma = "emma";
// Kontrollera om användaren är inloggad
if (isset($_SESSION["user_id"])) { // WO
echo $sql;
exit;
}
?>
<html id="wholly">
<head id="swollyness">
<title>Forum Board</title>
<style id='newsner' id="krejs">
.iBo {
background-color: #d4edda--; /* Grön bakgrund */
padding: 10px;
margin: 5px 0;
border-radius: 5px;
border: 1px solid #a9dfbf;
font-family: inherit--;
}
</style>
<link rel="stylesheet" href="css/styles.css"/>
</head>
<body>
<h1>Forum Board</h1>
<?php if (): ?> <!--Here I have a problem-->
<span style="background: yellow !important;">Under konstruktion</span>
<h2>Skicka ett meddelande!:</h2>
<form method="get" action="index.php">
<textarea name="iBo" rows="4" cols="50"></textarea><br>
<input type="submit" value="Skicka!">
</form>
<?php endif; ?>
<h2>Meddelanden</h2>
<ul>
<a href='register.php'>Registrera konto</a> || <?= htmlspecialchars($loggedin); ?>
<?=
include 'db-connect.php';
include 'functions.php';
$sql = "SELECT id, iBo, created_At FROM forum_posts ORDER BY created_At DESC";
$result = $conn->query($sql);
if ($result && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<li class=\"iBo\">" . htmlspecialchars(format_id($row["id"])) . ": " . htmlspecialchars($row["created_At"]) . " - " . htmlspecialchars($row["iBo"]) . "</li>";
}
} else {
echo "<li>Ingenting här.</li>";
}
$conn->close();
?>
</ul>
</body>
</html>