Re: For Loop Problems

From: Date: Wed, 28 Jul 2004 11:33:20 +0000
Subject: Re: For Loop Problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-192085@lists.php.net to get a copy of this message
php-list@xenonsolutions.com wrote:
Hello Everyone, I'm building a hotel management system and I can't seem to figure out why my for() loop doesn't work the way it should. I'm using patTemplate to create the HTML Template (I like using it and I don't want to start a pro/con template war). Here is the script: 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");
    }
I'm not aware of what patTemplate does, but my guess is that when you addVar() each time it is just pushing each variable into an array. In other words, you keep adding 7 elements onto the end of an array WITHOUT removing old elements. There is probably a removeVar method or something similar to help you with this. If not, then you probably need to have a different template variable for each row and then populate those template variables with 1 week's data.

« previous php.general (#192085) next »