Thanks David for your code.
Unfortunately the result is that nothing is displayed.
the complete code in the sidebar is:
foreach((get_the_category()) as $category)
{
$postcat= $category->cat_ID;
$catname =$category->cat_name;
}
<h2><?php echo $catname; ?></h2>
<?php $categories = get_categories("child_of=5"); foreach ($categories as $cat) { ?>
<?php query_posts("cat=$cat->cat_ID&showposts=-1&order=ASC&orderby=name"); ?>
<h3><?php single_cat_title(); ?></h3>
<?php while (have_posts()) : the_post(); ?>
<div class="what">
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to
<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
</div>
<?php endwhile; ?>
<?php } ?>
to make myself clear:
a code on the single.php which echos the subcategory and its posts would be great