PHP forum post not wokring

Im doing a project which is basically making a forum using PHP,HTML and MYSQL database. I basically using a PHP script to import data into the MySQL database and another PHP script to show all the data in the MySQL table on brower. So in a nut shell im using a combination of these two script to simulate a forum.

Ive got the these working which are:
create a new thread
display all the threads
create a new post
display all the posts

however the problem I have is that all posts data from the MySQL table is showing in every single thread, this shouldn't happen I only want the posts to show in the threads they correspond to, I taught it would do this automatically because did all the primary and foreign stuff with my three MySQL tables which are users,threads,posts bellow is the coding for my posts script and MySQL cmd.

I basically want to echo the rows in the posts table where thread_ID = to the threadID from the threads table, this is my primary and foreign key relationship.

<!-- Link to CSS-->
<link rel="stylesheet" type="text/css" href= "CSS/default.css" title="Main">
Welcome to the posts Page!!!!!!!!!
To start a new post fill in the details and...
<form name "input" action="new_post.php" method="post"></p>
<input type="text" name="thread_ID" size="25" value="Input thread ID here"><br>
<input type="text" name="description" size="25" value="Description"><br>
<input type="text" name="date" size="25" value="Post Date"><br>
<p><input type="submit" value="Submit"></p>
<form name "input" action="threads.php" method="post"></p>
<p><input type="submit" value="Back"></p>
<p>Click the "Submit" button to create a post.</p>
$mysqli = mysqli_connect("localhost", "root","","forum");
$myquery = "select * from posts";
$result = mysqli_query($mysqli,$myquery);
echo "<table>";
while($record = mysqli_fetch_array($result,MYSQL_ASSOC))
$sky = $record["postID"];
$ground = $record["thread_ID"];
$water = $record["description"];
$air = $record["date"];
echo "<tr>";
echo "<td>";
echo $sky;
echo "</td>";
echo "<td>";
echo $ground;
echo "</td>";
echo "<td>";
echo $water;
echo "</td>";
echo "<td>";
echo $air;
echo "</td>";
echo "</tr>";
echo "</table>";