470,855 Members | 1,301 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

sorting into collumns



I have data in a mysql databse. eg

ardvark
bee
clever
diva
elephant
fight
girl
heart
ink
joke
kill

I can retrive in alphabetical order without problem.

What i want to do is display in three rows with them sorted
downwards.. so bee is under ardvark and not in the next collumn

for HTML purposes I devided the total results by three and placed into
three tables which I then displayed side by side.. This also works for
printing...

However i want to also save the results to file and thus the format
has to be in ASCII using data and \t and \n etc but I cant get into
the same three collumns like that :(

Any help appreciated :)

Jul 17 '05 #1
2 1594
Sam
On Wed, 03 Dec 2003 14:07:58 +0000, mail wrote:


I have data in a mysql databse. eg

ardvark
bee
clever
diva
elephant
fight
girl
heart
ink
joke
kill

I can retrive in alphabetical order without problem.

What i want to do is display in three rows with them sorted
downwards.. so bee is under ardvark and not in the next collumn

for HTML purposes I devided the total results by three and placed into
three tables which I then displayed side by side.. This also works for
printing...

However i want to also save the results to file and thus the format
has to be in ASCII using data and \t and \n etc but I cant get into
the same three collumns like that :(

Any help appreciated :)


something like:

$limit = sizeof($myarray);
for($i = 0; $i < ($limit / 3); $i++)
{
echo "$myarray[$i]\t
$myarray[$i + $limit]\t
$myarray[$i + ($limit * 2)]\n"
}

ought to do it, I think, modulo ($limit / 3) giving a sensible result.
Maybe it should be ($limit / 3) + 1. Whatever, this seems a sensible place
from which to start.

Sam
;)

Jul 17 '05 #2
On Wed, 03 Dec 2003 14:37:36 +0000, Sam
<sa*@SPAMSPAMSPAM.rexfeatures.com> wrote:
Any help appreciated :)
something like:


Yup:)

$limit = sizeof($myarray);
for($i = 0; $i < ($limit / 3); $i++)
{
echo "$myarray[$i]\t
$myarray[$i + $limit]\t
$myarray[$i + ($limit * 2)]\n"
}

ought to do it, I think, modulo ($limit / 3) giving a sensible result.
Maybe it should be ($limit / 3) + 1. Whatever, this seems a sensible place
from which to start.

correct.. $limit/3 worked a treat... plus of course taking arrays out
of string :)

Many thanks for your help much appreciated and now...sorted:)
--
KIPAX (www.kipax.com)
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by dont bother | last post: by
1 post views Thread by monomaniac21 | last post: by
5 posts views Thread by jrod11 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.