Support

Account

Home Forums General Issues Repeater Loop if else problem Reply To: Repeater Loop if else problem

  • 
    function live_match($id) {
     
    		
    	$live_count = 0;
    
    	if( have_rows('fixtures', $id) ):
    		while( have_rows('fixtures', $id) ): the_row(); 
    
    			$home 	= get_sub_field('home');
    			$away 	= get_sub_field('away');
    			$date 	= get_sub_field('date-time');
    			$video 	= get_sub_field('video');
    			$live 	= get_sub_field('live');
    
    			if ($live) : 
    			
    				$live_count++;
    
    				echo "<strong><a href='" . get_the_permalink( $id ) . "'>" . get_the_title( $id ) . "</a></strong>";
    				echo "<div class='match mt-15'>";
    				echo "<div class='row'>";
    				echo "<div class='col-md-4'><img src='" . get_template_directory_uri() . "/img/" . $home . ".jpg' /></div>";			
    				echo "<div class='col-md-4'><h2 class='mb-5'>VS</h2><span>" . $date . "</span><span>Venue</span></div>";
    				echo "<div class='col-md-4'><img src='" . get_template_directory_uri() . "/img/" . $away . ".jpg' /></div>";
    				echo "</div>";
    				echo "</div>";
    
    			endif;
    
    		endwhile;
    
    	endif;
    	
    	if (!$live_count) {
    		echo 'No Match'; 
    	}
    
    }