I'm utilizing an if elseif statement to check on what page it's, also it mandates that you will find posts around the page then when searching is came back with a direct result , my code reduces. Any ideas how you can code this better?

this code is within my sidebar and it is showing the current articles, you can observe one particular search working here(the sidebar is setup like a sub-footer): http://ivry.sweetyams.ca/?s=new

along with a search no longer working here: http://ivry.sweetyams.ca/?s=asjdfkl%3B

Code I'm using: (I've attempted putting stuff in to the elsedoes not work either because you will find no posts around the 'nothing found' search page

<?php if (have_posts()) : ?>
<?php /* IF SEARCH PAGE */  if (is_search() ) { ?>
  <?php query_posts('category_name=0&showposts=5'); ?>
  <?php while (have_posts()) : the_post(); ?>
        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
        <p> <?php the_title(); ?></p>
        </a>
  <?php endwhile;?>

<?php /* IF ESCALADE PAGE */ }elseif (is_category_or_sub(6)) { ?>
  <?php query_posts('category_name=escalade&showposts=5'); ?>
  <?php while (have_posts()) : the_post(); ?>
        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
        <p> <?php the_title(); ?></p>
        </a>
  <?php endwhile;?>

<?php /* IF MONTAGNE PAGE */ } elseif (is_category_or_sub(14)) { ?>
  <?php query_posts('category_name=montagne&showposts=5'); ?>
  <?php while (have_posts()) : the_post(); ?>
        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
        <p> <?php the_title(); ?></p>
        </a>
  <?php endwhile;?>

<?php } else { ?>
DO SOMETHING ELSE
<?php }?>
<?php endif; ?>`

I'm looking to get all recent articles for my sidebar so when there's no increase the risk for search, additionally, it stops my sidebar from working.

The code I added isn't during my search page however in my SIDEBAR, it separates your comments ought to into 2 groups, (6 and 14) I'm basically splitting my website using groups for navigation, anything growing up below 6 is going to be styled one of the ways and 14 another, you can observe the main difference around the escalade and montagne links:

This really is getting every publish below escalade, OR every publish underneath the montagne category

My search pulls is a result of ALL groups, but when there's no google listing, for whatever reason my sidebar code, the code I incorporated, does not work.

first, showposts is deprecited since v2.1, used posts_per_page rather.

second, after each query_post, you have to totally reset the query such as this:

<?php
// The Query
query_posts( $args );

// The Loop
while ( have_posts() ) : the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

// Reset Query
wp_reset_query();
?>

this is the way I realize it. see more detail here:query_posts(), hope this can help.