RE: [PHP] Creating Rows and Columns Using for() Loops

From: Date: Fri, 09 Jul 2004 02:05:00 +0000
Subject: RE: [PHP] Creating Rows and Columns Using for() Loops
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-190016@lists.php.net to get a copy of this message
I wrote this in plain text. I hope it came out well... -----Original Message----- From: php-list@xenonsolutions.com [mailto:php-list@xenonsolutions.com] Sent: Thursday, July 08, 2004 9:02 PM To: php-general@lists.php.net Subject: RE: [PHP] Creating Rows and Columns Using for() Loops Chris, It's a little difficult to do in ascii, but here's an attempt. This is a simple hotel/motel log of who's staying in certain rooms. The 7 columns are the 7 days in the week and guest names fall under whichever date they checked in. So, let's see if I can give you a visual representation of this. I will only include two columns and a few rows, for now. You may have to fix your viewing window to allow this table to expand horizontally... |--------------------------|--------------------------|--------------------- -----| | MON JUL 5 | TUE JUL 6 | etc... | -----|--------|--------------------------|--------------------------|------- -------------------|--------|-----| Rm # |Rm Type | First Name | Last Name | First Name | Last Name | etc... |Rm Type |Rm # | -----|--------|--------------------------|--------------------------|------- -------------------|--------|-----| 101 | NQQ | Isaac Newton | (empty room) | etc... | NQQ |101 | -----|--------|--------------------------|--------------------------|------- -------------------|--------|-----| 102 | NK | Alexander Flemming | Alexander Flemming | etc... | NK |102 | -----|--------|--------------------------|--------------------------|------- -------------------|--------|-----| 103 | K | Charles Darwin | Robert Kennedy | etc... | K |103 | -----|--------|--------------------------|--------------------------|------- -------------------|--------|-----| 104 | QQ | Roger Rabbit | (empty room) | etc... | QQ |104 | -----|--------|--------------------------|--------------------------|------- -------------------|--------|-----| ... | ... | ... etc | ... etc | etc... | ... |... | -----|--------|--------------------------|--------------------------|------- -------------------|--------|-----| Thanks... -----Original Message----- From: barophobia [mailto:barophobia@gmail.com] Sent: Thursday, July 08, 2004 6:54 PM To: php-list@xenonsolutions.com Cc: php-general@lists.php.net Subject: Re: [PHP] Creating Rows and Columns Using for() Loops On Thu, 8 Jul 2004 18:17:25 -0500, php-list@xenonsolutions.com <php-list@xenonsolutions.com> wrote: > for ($i = 0; $i < count($num_days); $i++) { [snip] > for ($j = 0; $j < 32; $j++) { [snip] > } [snip] > } > How do I fix it to where each date column has > exactly 32 rows of guest names? it looks like you need to set up your loops the other way around. right now your code is like this: for (columns) { for (rows) { } } you want: for (rows) { for (columns) { } } explained in english: you need to handle one row/person at a time and not one column/date at a time. on the other hand i'm not sure i totally understand your desired output, so maybe a quick ascii table would help me/us? chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#190016) next »