I'm busy with an WordPress website and use Advanced Custom Fields plugin. Having a problem with made a table, so there are option wich are true or false. I will add an screenshot of the result I have so far.
Here is the current code:
<div id="abonnementen-table">
<table class="table table-hover">
<thead>
<tr>
<th>Specificaties</th>
<?php foreach($abonnementen as $abonnement){?>
<th><?php echo $abonnement->post_title;?></th>
<?php }?>
</tr>
</thead>
<tbody>
<?php
$field = get_field_object('uitgebreide_specs',$abonnement->ID);
$choices = $field['choices'];
foreach ($choices as $choice_value => $choice_label){
?>
<tr>
<td><?php echo $choice_label;?></td>
<?php
foreach($abonnementen as $abonnement){
$values = get_field('uitgebreide_specs',$abonnement->ID);
$field = get_field_object('uitgebreide_specs',$abonnement->ID);
$choices = $field['choices'];
foreach ($values as $value) {
if ($value['value'] == $choice_value) {
echo '<td><i class="fas fa-check"></i></td>';
}
}
?>
<?php }?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
The problem is of the code above if it is checked it works good, but if the option is unchecked there is an problem. The screenshot will show you my problem:
I have tried to put an else at this point:
if ($value['value'] == $choice_value) {
echo '<td><i class="fas fa-check"></i></td>';
}else{
echo '<td></td>'; // unchecked
}
But than I have to much collumns see screenshot below, can somebody tell me what i do wrong!
Thanks
Aucun commentaire:
Enregistrer un commentaire