I have a problem with my php code in Joomla. Shows all the titles that are in the database, but when I click on a title opens the shadowbox with div and always shows with the same title, description and date. why?
$db->setQuery($query);
$rows = $db->loadObjectList();
<ul class="mostread">
<?php foreach ($rows as $row) : ?>
<li>
<a rel="shadowbox" href="#open"><?php echo $row->title ?></a>
<div id="open" style="display:none;">
<div id="content" style="color:#FFF; padding:10px;">
Title:<?php echo $row->titulo ?><br>
Descripton:<?php echo $row->descripton ?><br>
Published:<?php echo $row->date ?><br>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
Try below code:
$db->setQuery($query);
$rows = $db->loadObjectList();
<ul class="mostread">
<?php $i=0; foreach ($rows as $row) : ?>
<li>
<a rel="shadowbox" href="#open_<?php echo $i?>"><?php echo $row->title ?></a>
<div id="open_<?php echo $i?>" style="display:none;">
<div id="content_<?php echo $i?>" style="color:#FFF; padding:10px;">
Title:<?php echo $row->titulo ?><br>
Descripton:<?php echo $row->descripton ?><br>
Published:<?php echo $row->date ?><br>
</div>
</div>
</li>
<?php $i++; endforeach; ?>
</ul>