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 8272025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:00:10+00:00 2026-06-08T07:00:10+00:00

I have a PHP array that produces four columns per row of a table.

  • 0

I have a PHP array that produces four columns per row of a table.
Is there anyway to force an HTML table to display 8 columns per row?

For example if my output is:

<tr>
<td>COL 1</td>
<td>COL 2</td>
<td>COL 3</td>
<td>COL 4</td>
</tr>
<tr>
<td>COL 5</td>
<td>COL 6</td>
<td>COL 7</td>
<td>COL 8</td>
</tr>
<tr>
<td>COL 9</td>
<td>COL 10</td>
<td>COL 11</td>
<td>COL 12</td>
</tr>
<tr>
<td>COL 13</td>
<td>COL 14</td>
<td>COL 15</td>
<td>COL 16</td>
</tr>

And the display looks like:

COL 1 COL 2 COL 3 COL 4
COL 5 COL 6 COL 7 COL 8
COL 9 COL 10 COL 11 COL 12
COL 13 COL 14 COL 15 COL 16

Is there anyway CSS or HTMl can force the table to display eight columns on a single line before breaking? So create something like this?

COL 1 COL 2 COL 3 COL 4      COL 5 COL 6 COL 7 COL 8
COL 9 COL 10 COL 11 COL 12   COL 13 COL 14 COL 15 COL 16
  • 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-06-08T07:00:13+00:00Added an answer on June 8, 2026 at 7:00 am

    Just change your PHP to format it the correct way or use divs and style it accordingly, however if its true tabular data id use tables and fix your PHP to represent what you want.

    It really isnt all that difficult in PHP, you could for example just have a counter and when that counter % 2 == 0 then finish the row and start a new one. Increase the counter accordingly.

    Pseudo code

    Currently you have something like this.

    for($i = 0; $i < numRows; $i++) {
        output a <tr> tag
    
        output <td> tags and data
    
        output a closing </tr> tag
    }
    

    What you need to do is something like this.

    for($i = 0; $i < numRows; $i++)  {
        if($i % 2 == 0)
            output startting <tr> tag
    
        output some <td> tags with data
    
        if(($i +1) % 2 == 0)
            output closing <tr> tag
    }
    

    Alternatley you could just use a boolean flag

    is_even_row = ture;
    for each row {
        if(is_even_row)
            output start tag
    
        output data for row
    
        if(not is_even_row)
            output end tag
    
        is_even_row = not is_even_row
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP array that produces four columns per row of a table.
I have a php page that produces an array of elements. For the sake
I have a php array that has a bunch of data that I need
I have a PHP array that looks like this: Array{ [0] { 'id' =>
In PHP I have an array that looks like this: $array[0]['width'] = '100'; $array[0]['height']
I have php code that puts some values into an Array as follows: $hunter=addslashes($MessageArray[1]);
I have an multi-dimensional array that I want to send to a PHP script
I have an array in php that contains all the lines of a text
I have a PHP file that contains a large array (about 90KB). I'm considering
I have a PHP function that builds a JSON array via $jsonArray= array(); for

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.