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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:07:17+00:00 2026-06-14T05:07:17+00:00

I’m attempting to retrieve all that data from a database, put it in a

  • 0

I’m attempting to retrieve all that data from a database, put it in a table (more than one table if necessary) and display them column-wise in lots of 4 split across multiple pages.

I would like to know how I would get the tables to display horizontally e.g.

Table Header   Table Header  Table Header
Table Data       Table Data      Table Data
Table Data       Table Data      Table Data

Rather than:

Table Header
Table Data
Table Data

Table Header
Table Data etc.

Here is the code so far:

// While loop that will display the results in groups of 4
while($row=sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC))
{ $newDate = $row['datenow']->format('d/m/Y'); ?>

<table id="syncresults">
<thead>
    <tr>
        <th scope="col" id="dateheader"> <?php echo $newDate ?></th>
    </tr>
</thead>

<tbody>
    <tr>
        <td><?php echo $row['nbsactive']; ?></td>
    </tr>
    <tr>
        <td><?php echo $row['nbsmanysynced']; ?></td>
    </tr>
    <tr>
        <td><?php echo $row['nbsthreedays']; ?></td>
    </tr>
</tbody>

Any suggestions on how to do this or to point me in the right direction would be greatly appreciated.

  • 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-14T05:07:19+00:00Added an answer on June 14, 2026 at 5:07 am

    There’s not enough information here to say whether or not you should be using a table because you provided non-data.

    If we’re writing a closet organization application, our data might come out of the database like this:

    John | Shoes | 3
    John | Pants | 10
    Sally | Shoes | 12
    Sally | Pants | 8
    Billy | Shoes | 4
    Billy | Pants | 9
    Kate | Shoes | 6
    Kate | Pants | 6
    

    But we want to display it like this:

    Member | Shoes | Pants
    John | 3 | 10
    Sally | 12 | 8
    Billy | 4 | 9
    Kate | 6 | 6
    

    We would write our loop something like this:

    <table>
    <tr>
    <?
    $last = null;
    while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
        if ($last != $row['member']) {
            if ($last) { // $last is null on our first pass through the loop, so don't print the tr's
    ?>
    </tr>
    
    <tr>
    <?
            }
    ?>
        <td><?=$row['member']?></td>
    <?
            $last = $row['member'];
        }
    ?>
        <td><?=$row['quantity']?></td>
    <?
    }
    ?>
    </tr>
    </table>
    

    The headers? Well, typically I would recommend looping twice and resetting the pointer, but I don’t see the equivalent of mysql_data_seek or pg_result_seek for the interface you’re using, so I can’t help you any farther than this. Using output buffering on the first “row” of results combined with a collector variable gathering up all of the headers as an array can work without the need to reset the pointer.

    If you’re just wanting to spit out the results in 4 columns because you think it looks prettier and not because it expresses tabular data, using CSS columns would be the better way to go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the

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.