vendredi 29 juillet 2016

how to add condition in Nth row of the MySQL database fetching in codeigniter

I am using codeigniter and I am stuck in giving if condition in a database loop:

<?php 
foreach ( $gallery as $raw ) {

    $g_id = $raw->gallery_id;
    $src_z =$raw->zoom_img;
    $src_m = $raw->main_img;
    $src_t =$raw->thumb_img;
    echo "<a href='#' data-zoom-image='".base_url().$src_z."'"; 
    echo "data-image='".base_url().$src_m."' class='active d_block wrapper r_corners tr_all translucent m_bottom_10'>";
    echo "<img src='".base_url().$src_t."' alt='' class='r_corners'></a>"; 

    if ( /*row is 4th then add*/ ) { 
        echo "</li><li>";
    }
}
?>

If the row is the 4th then it should add </li><li> at the end.

Aucun commentaire:

Enregistrer un commentaire