Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6572415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:00:12+00:00 2026-05-25T15:00:12+00:00

I have a situation, I wish to have 3 word in 1 table data.

  • 0

I have a situation, I wish to have 3 word in 1 table data.

For example,
one, two, three

I want four to appear below.

For example.

  1. One, two, three,
  2. four, five, six,
  3. seven, eight, nine,
  4. and so on..

How do I achieve this using table. Am trying to incorporate this in cakephp. I am using for loop to list the numbers down.

<table>
    <tbody>
        <tr>  

            <?php foreach ($professionalPassion as $us): ?>


                <td>
        <legend><?php echo $us['PassionsUser']['passion_tag'] ?></legend>

        Type: <?php echo $us['PassionsUser']['type'] ?><br/>                                 
        Description: <?php echo $us['PassionsUser']['description'] ?><br/> 
        <?php echo $this->Html->link(__('Edit', true), array('controller' => 'PassionsUsers', 'action' => 'edit_passion', $us['PassionsUser']['id'])); ?> | 
        <?php echo $this->Html->link(__('Delete', true), array('controller' => 'PassionsUsers', 'action' => 'delete', $us['PassionsUser']['id'])); ?>

    <?php endforeach; ?>
</td>
</tr>

</tbody>
</table> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:00:12+00:00Added an answer on May 25, 2026 at 3:00 pm

    This is a helper function I wrote to do exactly that:

    function auto_table($cells, $cols, $class = '') {
      $table = '<table' . (empty($class) ? '' : ' class="' . $class . '"') .'><tbody><tr>';
    
      $current_col = 1;
      foreach ($cells as $cell) {
        // Add the cell
        $table .= "<td class=\"col-$current_col\">$cell</td>";
    
        if ($current_col % $cols == 0) {
          $table .= '</tr><tr>';
          $current_col = 1;
        }
        else {
          $current_col++;
        }
      }
    
      // Clear up
      $remaining = $cols - ($current_col == 1 ? 4 : ($current_col - 1));
      for ($i = 0; $i < $remaining; $i++) {
        $table .= '<td class="col-' . $current_col++ . '">&nbsp;</td>';
      }
    
      $table .= '</tr></tbody></table>';
    
      return $table;
    }
    

    $cells will contain your array of data, $cols the number of columns for the table, and $class any class to add to the table.

    UPDATE

    Integrated with your code:

    $cells = array();
    foreach ($professionalPassion as $us) {
      $cell = 'Type: ' . $us['PassionsUser']['type'] . '<br />';
      $cell .= 'Description: ' . $us['PassionsUser']['description'] . '<br />';
      $cell .= $this->Html->link(__('Edit', true), array('controller' => 'PassionsUsers', 'action' => 'edit_passion', $us['PassionsUser']['id']));
      $cell .= ' | ';
      $cell .= $this->Html->link(__('Delete', true), array('controller' => 'PassionsUsers', 'action' => 'delete', $us['PassionsUser']['id']));
      $cells[] = $cell;
    }
    
    $html_table = auto_table($cells, 3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the situation: I have inherited two separate machines, one used for development
I have situation where a user can manipulate a large set of data (presented
We have situation where say we have four engineers that are working on software
I have a situation where two objects of the same type have parents of
I have a table T (structure below) which initially contains all-NULL values in an
I have a situation in which i am plotting a dendrogram with data points
Situation: I have two fixed-height divs, overflow set to hidden on both, and dynamic
I have a situation where I have a few cygwin commands which I wish
Trying my hand with jQuery. I have this strange situation that i wish to
I have 2 desktop applications that I wish to integrate with external applications. One

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.