How to set up conditionals in page templates?

<?php
/*
Template Name:product
*/

get_header();

// check if product_id is not set or is empty string
if( !isset($_GET['product_id']) || '' == $_GET['product_id'] ) {
    // if so, run your query and display data
    $data = $wpdb->get_results("myquery Here");
    foreach($data as $row) {
        echo '<div>';
        echo '<p>Name:' . $row->p_name . '</p>';
        echo '<p>Price:' . $row->p_price. '</p>';
        // pass ID using GET
        echo '<p><a href="https://wordpress.stackexchange.com/questions/74298/?product_id=" . $row->p_id . '">VIEW PRODUCT</a></p>';
        echo '</div>';
    }
}
else {
    // product_id is set and is not empty
    require('/path/to/view_detail.php');
}

get_footer();

tech