![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
Regular Coder ![]() Join Date: Jul 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Split Results to Three Columns
I've never actually figured out how to do this. What I'm looking to do is query our database, get the results (which are simple names) and then output the results to a three column table with the results evenly divided up into each column. So, the table would look similar to:
result 1 | result 4 | result 7 result 2 | result 5 | result 8 result 3 | result 6 | result 9 The database is a very simple one. Just two rows: ID Name How do I accomplish this? |
|
|
|
|
|
PM User | #2 |
|
Master Coder ![]() ![]() Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
what server side language will you use to turn the recordset into a table?
regardles of the language, you best ue an incrementing variable and then check the modulus when you devide this incremental by 3.
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html |
|
|
|
|
|
PM User | #3 |
|
Regular Coder ![]() Join Date: Jul 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Raf,
You are always so quick to resond to my questions and are always so helpful! Thanks for that. I will be using PHP. If you could show me some sample code that I could use to edit to fit my needs, that will be very helpful. |
|
|
|
|
|
PM User | #4 |
|
Master Coder ![]() ![]() Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
here you go http://www.codingforums.com/showthre...hlight=modulus
--> contains links to two threads with examplecode
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html |
|
|
|
|
|
PM User | #5 |
|
Regular Coder ![]() Join Date: Jul 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
Raf,
I've got the following code that doesn't what I need. However, this lists the results as such: Name 1 | Name 2 | Name 3 Name 4 | Name 5 | Name 6 Name 7 | Name 8 | Name 9 I'd like to get it to list it like this: Name 1 | Name 4 | Name 7 Name 2 | Name 5 | Name 8 Name 3 | Name 6 | Name 9 The code is: PHP Code:
|
|
|
|
|
|
PM User | #6 |
|
Master Coder ![]() ![]() Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
![]() |
so kinda like a three column article or so ...
i would first build a 2D array where the first dimension is the row, and the second dimension is the column. Like $arr_cells[1][1] = Name1 $arr_cells[2][1] = Name2 $arr_cells[1][2] = Name4 and then turn that array into a table like PHP Code:
PHP Code:
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|