what is your data structure? it looks as though your probably have (at least) two tables: users and posts. if you simply want to find out how many post a user has then:
$result = "SELECT COUNT(*) AS post_count FROM posts WHERE user_id = '$user_id'";
i don't know you structure so this is just a guess at the table/field names.