Cycle one fails to build for browsing tabs:

<?php foreach($news as $new): ?> <div class="tab"> <input type="radio" id="tab-<?=$i?>" name="tab-group-1" checked> <label for="tab-<?=$i?>"> <?=$new['title']?> </label> <div class="content"> <p><?=$new['description']?></p> </div> </div> <?php endforeach; ?> 

Where $i should be, from 1 to 3 assume that there are three tabs.

  • @LLIAKAJI, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Vitalina

1 answer 1

$i not assigned to you, if it is a key, then try this:

  foreach($news as $i => $new) 

If it is critical that it is from 1 to 3, then

  id="tab-<?=$i + 1?>"