Jump to content

Problems with a loop


tigomark

Recommended Posts

I am having problems with my loop statement. Doing a var_dump shows that I am getting an integer of 1 and 2 (expected) for each row. But the variable is not holding it for some reason.

 

 


for ($i = 1; $i <= $this->formhandler; $i++){
    $reporthtml .= sprintf("<td>%s</td>", $entry->reported_value[$i]);
var_dump($i);
}

Link to comment
https://forums.phpfreaks.com/topic/91309-problems-with-a-loop/
Share on other sites

I got it

 

  	for ($i = 1; $i <= $this->formhandler; $i++){
$v = "reported_value".$i;
    $reporthtml .= sprintf("<td>%s</td>", $entry->$v);
//var_dump($entry->reported_value[$i]);
}

 

 

However I now have another problem to get this to work and that is to create a header that limits itself by the same array

 

 


if (is_array($this->dataTypes->data)) { 
reset($this->dataTypes->data); 
while (list($key, $val) = each ($this->dataTypes->data)) {
if (($val->type != "N/A") && ($key <= $this->formhandler)) { 
$reporthtml .= sprintf("<td align=\"center\" nowrap=\"nowrap\">%s</td>", $val->name); 
} //
$reporthtml .= sprintf("<td align=\"center\" nowrap=\"nowrap\">%s</td>", $val->name); 
}
}

Link to comment
https://forums.phpfreaks.com/topic/91309-problems-with-a-loop/#findComment-467980
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.