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

    (@jonua)

    I did a basic example on http://codepen.io/johannheyne/pen/YPooYq/ for you, how to give the table cells a border and how to remove the space between the cells.

    Good luck!

    Thread Starter voanhkhach

    (@voanhkhach)

    thanks you
    but i can’t apply it to field
    can you help me add to this code

    <?php 
    
    $rows = get_field('repeater_field_name');
    if($rows)
    {
    	echo '<ul>';
    
    	foreach($rows as $row)
    	{
    		echo '<li>sub_field_1 = ' . $row['sub_field_1'] . ', sub_field_2 = ' . $row['sub_field_2'] .', etc</li>';
    	}
    
    	echo '</ul>';
    }
    ?>

    Plugin Author Johann Heyne

    (@jonua)

    Sorry, but I do not understand your question. Your code is about an repeater field and puts out a list and not a table.

    Thread Starter voanhkhach

    (@voanhkhach)

    yes i want display repeatfield in table

    Plugin Author Johann Heyne

    (@jonua)

    Maybe this is what helps you displaying a repeater fields content as a table.

    <?php 
    
    	$rows = get_field( 'repeater_field_name' );
    
    	if ( $rows )
    	{
    		echo '<table>';
    
    		foreach( $rows as $row )
    		{
    			echo '<tr>';
    
    				foreach ( $row as $cell )
    				{
    					echo '<td>' . $cell . '</td>';
    				}
    
    			echo '</tr>';
    		}
    
    		echo '</table>';
    	}
    
    ?>
    Thread Starter voanhkhach

    (@voanhkhach)

    i have try with your new code but
    it not sucess
    you can see
    it display
    http://oi60.tinypic.com/357rs5t.jpg

    Plugin Author Johann Heyne

    (@jonua)

    <?php 
    
    	$rows = get_field( 'repeater_field_name' );
    
    	if ( $rows )
    	{
    		echo '<table class="table">';
    
    		foreach( $rows as $row )
    		{
    			echo '<tr>';
    
    				foreach ( $row as $key => $value )
    				{
    					echo '<td>' . $value . '</td>';
    				}
    
    			echo '</tr>';
    		}
    
    		echo '</table>';
    	}
    
    ?>

    In the stylessheet:

    .table td {
      border: 1px solid black;
    }
    
    /* removing space between cells and let the cell borders collapse */
    .table {
      border-collapse: collapse;
    }
    Thread Starter voanhkhach

    (@voanhkhach)

    this is my code

    <?php 
    
    	$rows = get_field('repeater_field_name');
    	if($rows)
    	{
    
    		echo '<table class="table">';
    
    		foreach($rows as $row)
    		{
    			echo '<tr>';
    				foreach ( $row as $key => $value )
    				{
    					echo '<td>Channel:' . $value['channel_link'] .', Link:' . $value['link_live'] .', etc</td>';
    
    				}
    			echo '</tr>';
    		}
    
    		echo '</table>';
    
    	}
    ?>

    i have use your code but it get value not true
    i want display Value in a table and link and a table
    you can see pic

    http://oi62.tinypic.com/289l8nb.jpg
    http://oi60.tinypic.com/6igns1.jpg
    http://oi59.tinypic.com/2a6petw.jpg

    Plugin Author Johann Heyne

    (@jonua)

    OK, try this…

    <?php 
    
    	$rows = get_field('repeater_field_name');
    	if($rows)
    	{
    		echo '<table class="table">';
    
    		foreach($rows as $row)
    		{
    			echo '<tr>';
    				foreach ( $row => $fields )
    				{
    					echo '<td>Channel:' . $fields['channel_link'] .', Link:' . $fields['link_live'] .', etc</td>';
    
    				}
    			echo '</tr>';
    		}
    
    		echo '</table>';
    
    	}
    ?>
    Thread Starter voanhkhach

    (@voanhkhach)

    Thanks you very much

    <?php

    $rows = get_field(‘repeater_field_name’);
    if($rows)
    {
    echo ‘<table class=”table”>’;

    foreach($rows as $row)
    {
    echo ‘<tr>’;
    foreach ( $row => $fields )
    {
    echo ‘<td>Channel:’ . $fields[‘channel_link’] .’, Link:’ . $fields[‘link_live’] .’, etc</td>’;

    }
    echo ‘</tr>’;
    }

    echo ‘</table>’;

    }
    ?>

    i have try with this code but it report error whitepage.
    i have try $row as $key => $fields but i receive same this picture
    http://oi60.tinypic.com/6igns1.jpg

    i think it can’t doing with my request

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘help me border and padding table’ is closed to new replies.