So i have almost finished making a blog from scratch. I can login and logout from admin panel. And from the adminpanel I can add/edit/delete posts and categories.

I have tre mysql tables which are posts, users, categories.

My question is regarding echoing out the categories and posts.

On my right side of the blogpage i have the standard "latest posts" sidebar. The thing I don't know how do do is how to echo out the posttitles under the correct category, right now i dont even echo out the categories only the titles like this:

Code PHP:
function getTitles() {
	$query = mysql_query("SELECT * FROM posts ORDER BY `ID` DESC") or die(mysql_error());
	while($post = mysql_fetch_assoc($query)) {
		echo "<h3><a href=\"singlePost.php?=" . $post['Title'] . "\">" . $post['Title'] . "</a></h3>";

WHat should i add to this to echo out the categories and get the correct titles under the correct category? I guess it has something to do with the Category_ID row i have in my post table?