So i'm pretty new to MySqli and PHP and I'm trying to create a forum. I'm now stuck at this point, I get the forum to show my "boards" and "threads" but it shows the same threads on every board. Also, no matter which thread i click on it always takes me to the same one. This is the code for my view-thread.php.
<?php
include 'forumdb.php';
$board_id = $_GET['board_id'];
$thread_id = $_GET['thread_id'];
$get_board = $mysqli->query("SELECT * FROM boards WHERE board_id = $board_id");
$board_data = $get_board->fetch_assoc();
$get_thread = $mysqli->query("SELECT * FROM threads WHERE thread_id = $thread_id");
$thread_data = $get_thread->fetch_assoc();
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $thread_data['thread_title'] ?></title>
</head>
<body>
<a href="forum.php">Home</a> | <a href="view-board.php?board_id=<?php echo $board_id ?>"><?php echo $board_data['board_name'] ?></a> | <b><?php echo $thread_data['thread_title'] ?></b><br><br>
Title: <b><?php echo $thread_data['thread_title'] ?></b><br><br>
<b>Content:</b><br>
<?php echo $thread_data['thread_content'] ?>
</body>
</html>
And this is my code for my view-board.php
<?php
include 'forumdb.php';
$board_id = $_GET['board_id'];
$get_board = $mysqli->query("SELECT * FROM boards WHERE board_id = $board_id");
$board_data = $get_board->fetch_assoc();
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $board_data['board_name'] ?></title>
</head>
<body>
<a href="forum.php">Home</a> | <b><?php echo $board_data['board_name']; ?></b><br><br>
<a href="add-thread.php?board_id=<?php echo $board_id ?>">Post New Thread</a><br><br>
<?php
$threads = $mysqli->query("SELECT * FROM threads WHERE board_id = $board_id");
while ($thread_data = $threads->fetch_assoc()) { ?>
<b>#<?php echo $thread_data['thread_id'] ?></b> <a href="view-thread.php?thread_id=<?php echo $thread_data['thread_id'] ?>&board_id=<?php echo $board_id ?>"><?php echo $thread_data['thread_title'] ?></a>
<?php }
if ($threads->num_rows == null) {
echo '<br><br>no threads posted yet';
}
?>
</body>
</html>