Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Ok, if you want to have have members 1-10 in one column, you can't output the html with a simple loop, because it always works from left to right.
So you just put all results into an array.
Your array looks like this:
$array['0'] = "member1";
$array['1'] = "member2";
$array['2'] = "member3";
...
$array['19'] = "member20";

Next thing is to "reorganzie" the array so that every value is in the position you need it for the output. You could to that by splitting up the array into two different ones. One for the left column and one for the right column.

//You know the total number of results, so each array needs to store half of it
$arraysize = $totalrows / 2 ;
// first half results in the left array
$leftarray = = array_slice ($array, 0,$arraysize);
// second in the right array
$leftarray = = array_slice ($array, $arraysize);
for ($i=0;$i < $totalrows /2 ;$i++){
echo "<tr><td>$leftarray[$i]</td><td>$leftarray[$i]</td></tr>
}

A different solution would be to use the result array and do some calculations which array element needs to be printed.
Basically, you'd do:
$rowstoprint = $totalrows / 2 ;
for ($i=0;$i < $totalrows /2 ;$i++){
echo "<tr><td>$result[$i]</td><td>$result[$i + $rowstoprint]</td></tr>
}

Sponsored Links
Entire Thread
Subject Posted By Posted
Breaking Results up into two rows omegatron 01/19/2004 7:53 PM
Re: Breaking Results up into two rows Astaran 01/19/2004 9:18 PM
Re: Breaking Results up into two rows omegatron 01/19/2004 11:10 PM
Re: Breaking Results up into two rows Astaran 01/20/2004 2:04 AM
Re: Breaking Results up into two rows omegatron 01/20/2004 4:08 AM
Re: Breaking Results up into two rows JoshPet 01/20/2004 5:56 AM
Re: Breaking Results up into two rows omegatron 01/20/2004 6:03 AM
Re: Breaking Results up into two rows omegatron 01/20/2004 6:39 AM
Re: Breaking Results up into two rows Astaran 01/20/2004 8:32 AM
Re: Breaking Results up into two rows omegatron 01/20/2004 3:49 PM
Re: Breaking Results up into two rows Astaran 01/20/2004 4:55 PM
Re: Breaking Results up into two rows omegatron 01/20/2004 5:11 PM
Re: Breaking Results up into two rows Astaran 01/20/2004 6:29 PM
Re: Breaking Results up into two rows omegatron 01/20/2004 7:32 PM
Re: Breaking Results up into two rows Astaran 01/20/2004 7:58 PM
Re: Breaking Results up into two rows omegatron 01/20/2004 8:15 PM
Re: Breaking Results up into two rows Astaran 01/20/2004 8:32 PM
Re: Breaking Results up into two rows omegatron 01/20/2004 9:20 PM
Re: Breaking Results up into two rows Astaran 01/20/2004 9:43 PM
Re: Breaking Results up into two rows omegatron 01/20/2004 10:21 PM
Re: Breaking Results up into two rows Astaran 01/20/2004 11:42 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,834
Joined: January 2000
Forum Statistics
Forums63
Topics37,583
Posts293,957
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 6013
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 14
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
isaac 2
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20261026)