Re: For Loop Problems

From: Date: Wed, 28 Jul 2004 11:23:46 +0000
Subject: Re: For Loop Problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-192081@lists.php.net to get a copy of this message
<php-list@xenonsolutions.com> wrote in message news:php.general-192079@news.php.net... > > for ($j = 0; $j < 32; $j++) { > for ($i = 0; $i < count($num_days); $i++) { > $template->addVar("room_num", "ROOM_NUM", '101'); > $template->addVar("room_type", "ROOM_TYPE", 'NQQ'); > $template->addVar("guest_NameRate", "GUEST_NAME", 'NAVID > YAR'); > $template->addVar("guest_NameRate", "GUEST_ID", > 'fname'); > $template->addVar("guest_NameRate", "CLASS_GUEST", > 'fname'); > $template->addVar("guest_NameRate", "ROOM_RATE", > '49.95'); > $template->parseTemplate("guest_NameRate", "a"); > } > $template->parseTemplate("guest_row", "a"); > } > > This inner for() loop works great. It creates a SINGLE row with 7 columns of > data (one column for each day of the week). However, the outer for() loop > does not work like it should. I want it to display 32 rows of 7 columns per > row. But what happens is that on every row after the first row it appends 7 > more columns at the end of each row. So row 2 will have 14 columns, row 3 > will have 21 columns, row 4 will have 28 columns, and so on. I can't figure > out why this is. Either it's something new in PHP5 or I'm doing something > really stupid. I am sending a PDF attachment of a snapshot showing a hint, > made purely with HTML, of what I am trying to achieve. If anyone can help me > it would be greatly appreciated. Thanks guys. I seriously doubt that php has problems to execute for loop correctly, you are probably missusing your template system. Say what does "a" stand for in: $template->parseTemplate("guest_NameRate", "a"); if it stands for append, than maybe in second pass through the loop you add 7 fiends to allready existing 7, in 3. pass you add 7 more to 14 existing, etc.. rush -- http://www.templatetamer.com/

« previous php.general (#192081) next »