Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Johann Heyne

    (@jonua)

    You can do this by your own…

    foreach ( $table['body'] as $tr ) {
        echo '<tr>';
            $i = 0;
            foreach ( $tr as $td ) {
                echo '<td class="td' . $i++ . '">';
                    echo $td['c'];
                echo '</td>';
            }
        echo '</tr>';
    }
    
    // result…
    <tr>
        <td class="td1">TD one</td>
        <td class="td2">TD two</td>
    </tr>

    Or you can use CSS like…

    .your-table-class td:nth-child(1) {
        /* styles for first td */
    }
    .your-table-class td:nth-child(2) {
        /* styles for second td */
    }

    Or may you ment this…

    foreach ( $table['body'] as $tr ) {
        echo '<tr>';
            $i = count( $tr );
            foreach ( $tr as $td ) {
                echo '<td class="td' . $i . '">';
                    echo $td['c'];
                echo '</td>';
            }
        echo '</tr>';
    }
    
    // result…
    <tr>
        <td class="td2">TD one</td>
        <td class="td2">TD two</td>
    </tr>

    Thread Starter ps3hero

    (@ps3hero)

    yes, this works, thanks a lot for your help ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add count classes to TR and TD’ is closed to new replies.