I wrote this in plain text. I hope it came out well...
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 08, 2004 9:02 PM
To: [EMAIL PROTECTED]
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:[EMAIL PROTECTED]
Sent: Thursday, July 08, 2004 6:54 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Creating Rows and Columns Using for() Loops
On Thu, 8 Jul 2004 18:17:25 -0500, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> 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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php