Jump to content


Photo

Make Query Start New Row After Three Columns?


  • Please log in to reply
5 replies to this topic

#1 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 27 September 2006 - 11:29 PM

I'm trying to make it so that if I pull thirty rows from a database, they they go into three columns. However, I want them to begin a new row after they go through a column. I'm really bad at explaining stuff. Let's pretend I have thirty rows with incrementive numbers from one to thirty. I want it to do this when it pulls from the database:

01 02 03
04 05 06
07 08 09
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30

Does that make sense? I want a maximum of three columns. The more rows there are in the database, the more rows that would need to be made in the output. Can anyone direct me in the right way?

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 September 2006 - 12:20 AM

This is a layout issue... deal with it in PHP.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 28 September 2006 - 07:07 AM

I don't understand why it'd be a layout issue. It would require queries, would it not?

I'm not looking for just the cosmetics part of it. I want to know how to do it all. The query and all.

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 September 2006 - 02:48 PM

Because having 3 columns is layout... write a query that retrieves them all, and start a new row after every 3rd value.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 28 September 2006 - 09:12 PM

I have no idea how to do that. >_> The only way I know how to do that would look like:

1 1 1
2 2 2
3 3 3
4 4 4

.. and so on. =(

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 September 2006 - 02:52 AM

Just keep a count as you iterate though the results... if you're not sure how to do this, create a new thread in the PHP forum.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users