guessing from your problem, you could save your slug in your database upon creation, and use that one to identify the post also (most likely always will be unique, and if not use something as a date to go with it or just add the id to the end of it?). in your posts.php file then you begin with
if(isset($_GET['id'])) { //your post identifier, if this is set, show a post
include("postdetails.php");
} else {
//your posts code
}
on your index you then include the page if it is being called:
if(isset($_GET['p'])) {
include($_GET['p'] . '.php'); //include the page you want, it is a seperate php page
}
and for your htaccess, you use something like this (code based upon something i use myself), where $p is the page you are on (to make it more website friendly, in your case this would be posts, or any other page) and the id is the next variable. if you use this however, all pages you create must use these two variables, so you need to rename any other scripts to use these variables. more can be added in similar fashion of course.
RewriteEngine On
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?p=$1&id=$2&actie=$3
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?p=$1&id=$2
RewriteRule ^([^/\.]+)/?$ index.php?p=$1
this may be not the most elegant way to do it though, more experienced users should answer also.