'PHP : toggle button
I have a table where each row represents a single date (browsed with a foreach)
If the user is registered for a date, the "unsubscribe" button should appear and vice versa (another foreach).
My current code shows both buttons (user is registered on both dates)
<?php if (empty($inscriptions)) :?>
<button class="btn-inscription" data-id-date="<?php echo $row->date_ID?>">S'inscrire</button>
<?php else:
foreach ($inscriptions as $other) :
if ($row->date_ID == $other->ID) : ?>
<button class="btn-unregister" data-id-date="<?php echo $row->date_ID?>">Se désinscrire</button>
<?php else:?>
<button class="btn-inscription" data-id-date="<?php echo $row->date_ID?>">S'inscrire</button>
<?php endif; endforeach; ?>
<?php endif; ?>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

