I'm doing a project using: Php, css, html, mariadb "mysql"
I am trying to execute an If statement within a ForEach loop, but the "if" only executes in the first execution of the Foreach, in the rest everything is executed, except for the If. I do not understand what's happening.
Here my code:
As you can see, I have some rows and columns to show: first: an identifier, second: general information of the corresponding identifier third: in a progress bar I show certain information. fourth: I execute an if to determine what kind of information to show in another progress bar. fifth: I show two dates
This image shows how all the results should look:
This image shows that the second progress bar is not loaded in all results.
Here my code:
<?php
foreach ($records as $r) {
$p = 100 - $r->PT;
?>
<li class="list-group-item">
<div class="row">
<div class="col-md-1 text-center">
<a href="Consultas.php?OT=<?php echo escape($r->OT); ?>" class="btn btn-primary btn-xs" role="button" style="margin-top: 20px;"><?php echo escape($r->OT). ' '; ?><span class="glyphicon glyphicon-search"></span></a>
</div>
<div class="col-md-4">
<h6><?php echo escape($r->ingenio); ?></h6>
<h5><strong><?php echo escape($r->descripcion); ?></strong></h5>
</div>
<div class="col-md-6">
<div class="progress" style="margin-bottom: 0px; margin-top: 20px">
<div class="progress-bar progress-bar-success" role="progressbar" style="width:<?php echo escape($r->PT); ?>%"><?php echo escape($r->PT); ?>%</div>
<div class="progress-bar progress-bar-danger" role="progressbar" style="width:<?php echo escape($p); ?>%"><?php echo escape($p); ?>%</div>
</div>
<?php
echo escape($r->tMaza);
$var = escape($r->tMaza);
if ($var = "CMA") {
include_once 'PG_MazaConvencional.php';
} else if ($var = "CCB") {
include_once 'PG_MazaConvencional_CascoBurdo.php';
} else if ($var = "CCL") {
include_once 'PG_MazaConvencional_CascoLiso.php';
} else if ($var = "CCR") {
include_once 'PG_MazaConvencional_CascoRayado.php';
} else if ($var = "HMA") {
} else if ($var = "HCB") {
} else if ($var = "HCL") {
} else if ($var = "HCR") {
}
?>
</div>
<div class="col-md-1 text-center">
<span class="label label-warning"><?php echo escape($r->fecha_alta); ?></span> <br>
<span class="label label-danger"><?php echo escape($r->f_e_term); ?></span>
</div>
</div>
</li>
<?php
}