Jump to content

using a variable and making it keep track of changes


emehrkay

Recommended Posts

i dont know exactly what this is called but i do remember reading it somewhere.

i want use a variable, then if a condition is met add one to it. the way that i am trying to do is is while drawing a table. i have one cell that contains the variable

$no_waiver_count = 0;
...
$table .= "<tr><td colspan=\"4\">There are ". $$no_waiver_count ."...;

then there is a loop to draw the rest of the rows and inside of that loop is a condition and if it is met it will add one to the $no_waiver_count

if($index != -1){
$no_waiver_count++;
}

then when the loop is complete, i return $table. - i thought the double $$ would keep track of the changes but its not working, its only returning zero, when it should return 12.
Link to comment
Share on other sites

[!--quoteo(post=369238:date=Apr 27 2006, 10:18 AM:name=emehrkay)--][div class=\'quotetop\']QUOTE(emehrkay @ Apr 27 2006, 10:18 AM) [snapback]369238[/snapback][/div][div class=\'quotemain\'][!--quotec--]
i thought the double $$ would keep track of the changes but its not working, its only returning zero, when it should return 12.
[/quote]

you shouldn't need the double $$.

another example using a for loop

$var = 0;

for($i=0; $i<20; $i++){

if(condition){
$var = $var + 1;
}

}

echo $var;

Link to comment
Share on other sites

[!--quoteo(post=369244:date=Apr 27 2006, 10:38 AM:name=micah1701)--][div class=\'quotetop\']QUOTE(micah1701 @ Apr 27 2006, 10:38 AM) [snapback]369244[/snapback][/div][div class=\'quotemain\'][!--quotec--]
you shouldn't need the double $$.

another example using a for loop

$var = 0;

for($i=0; $i<20; $i++){

if(condition){
$var = $var + 1;
}

}

echo $var;
[/quote]


the problem is that i want to use it before the loop and i want it to change depending on what is in the loop. here is my code, maybe you guys can see some errors in my thinking

edit i tried to change it to a class property, but it still doesnt work

[code]
<?
    public function draw_page_all(){
        
        $data = $this-> get_participant_list ($this->_work_unit);
        $count = count($data);
                
        $table = "<table>\n";
        
        if($count == 1 && ($data[0]->person_id == 0 ||  $data[0]->person_id == "")){
            
            $table .= "<tr><td colspan=\"4\">There are no participants at this time who have elected to share their ". APP_SHORT_NAME ." Course Transcripts.</td></tr>\n";
        
        }else{
        
            $table .= "<tr><td colspan=\"4\">There are ". $this->_no_waiver_count ." from who have elected that they do not wish to share their transcrips or have not yet agreed to the waiver.</td></tr>\n";
        
            for($i = 0; $i < $count; $i++){
                //check to see if participant signed the waiver
                
                $w = new WaiverDAO();
                $wArr = $w->getIncompleteWaivers(array(STI_ID, $data[$i]->person_id));
                $index = LMS_MISC::getIndex($wArr, 'waiver_id', 2);
                
                if($index != -1){
                    $this->_no_waiver_count++;
                }else{
                    //display name and grab field info
                    $table .= "<tr><td colspan=\"4\">". $data[$i]->last_name .", ". $data[$i]->first_name ."</td></tr>\n";
                    $user_data = $this->get_data_user(STI_ID, $data[$i]->person_id);
                    $table .= $this->draw_page("all", $user_data);
                }                
            }
        }
        
    return    $table .= "</table>\n";
        
    }

}
?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.