Help with Wordpress conditions?

Struggling with this code, the conditions work, the only way I can get the wp_get_attachment_url is to loop through it but then this outputs as many images from the media library and I only want one?

  <div class="tvimage">
  <?php
    if ($imgurlbase != '' ) { ?>

    <img src="<?php bloginfo('template_url'); ?>/timthumb.php?src=<?php echo $imgurlbase . $imgfromtv; ?>&h=62&w=75" alt="<?php echo $programme; ?>">

            <?php } elseif ($imgurlbase == '' ) { ?>

            <?php
    $args = array(
        'post_type' => 'attachment',
        'numberposts' => -1,
        'post_status' => null,
        'post_parent' => null,
        ); 
    $attachments = get_posts( $args );


                foreach ( $attachments as $attachment ) {

                    if ($attachment->post_title == $programme) {
                            echo wp_get_attachment_url($attachment->ID);
                        }
                    else {
                    echo '<img src="';
                    echo bloginfo('template_url');
                    echo '/images/nontvimg.jpg" alt="no tv image" />';
                    }

                }


    ?>



            <?php } ?>


</div>

You could try using array_search() to seek out the specific attachment.