Jump to content

Splitting mySQL Results


Hartley

Recommended Posts

So I have a database, and I want to split the results into 2 columns. I don't want to alternate them, but have the first half in the left column, and the second half in the right column. How can I handle this so that it does it automatically no matter what number of entries (and so that if it's an odd number, the one overflow is on the left).

 

Thanks in advance.

Link to comment
Share on other sites

If you are alternating you can process the result set directly but in this situation is easiest to put the results is an array and output from the array.

 

If you have N rows ( where $rows = ceil(count($array)/2) )

for ($r=0; $r < N; $r++)

    new row
         output rth item          output (r+N)th item
    close row

end for

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.