jeudi 10 mai 2018

How to apply if-else on css class in php code?

I am trying to apply if else condition in bootstrap class with php variable but its not working. My variable is getting result. Below is my tbody where i am applying php code:

<div class="<?php '#count_rows#' <= '2')
        { 
            echo 'middle_menu';
        } 
    else 
        { 
            echo 'middle_menu1';
        } ?>">
        <table class="table_4">
            <thead>
                <tr>
                    <th class="th_11">Quantity</th>
                </tr>
            </thead>
            <tbody>
                #TABLE_BODY#
            </tbody>
        </table>
</div>

Below is my 2 css classes:

.middle_menu
    {
        margin-top: 40px;       
        padding-bottom: 200px;
    }
.middle_menu1
    {
        margin-top: 40px;
    }

I am fetching my variable from another page where i set this type of opening and closing variable with #. Below is my code for your reference but i dont think that is an issue for me because i check this #count_rows# variable with print_r in my current page and it showing me correct result.

foreach ($form_field as $key => $value){
    $htmlContent = str_replace('#'.$key.'#', $value, $htmlContent);
}

Aucun commentaire:

Enregistrer un commentaire