By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

sorting into collumns

P: n/a


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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.