I have a simple PHP foreach loop that generates some HTML, and as part of this it includes another file that generates some Javascript code. The include file echoes a variable that is set at the top of the foreach loop, but it is displaying the same value for all items in the loop.
Here's a cutdown version of the foreach loop:
foreach($records as $record){
$recid = $record->getRecordId();
if ($type == 'A') {
// set some variables
include('displayPopover.php');
} elseif ($type == 'B') {
// set some variables
include('displayPopover.php');
}
The displayPopover.php includes this:
<p><strong><?php echo $recid ?></strong></p>
When I view the page in the browser it's showing the same value for the string. Everything else in the foreach loop is updating for each record but not the code in the include file for some reason after the first iteration.