I have this code to echo out fields in a database alphabetically with headers for the letter of the alphabet they begin with. The information in the database isn’t wide enough to fit 100% width of the page so I would like to split the information into two separate divs and float them side by side.. The CSS is easy, but I am unsure how to split them. There are 50 items in the database so I want the first foreach statement to stop at 25 and then carry on from where it left off in the second div.
Here is my code:
<?php
$previousLetter = false;
?>
<?php foreach($this->clubs as $clubs) : ?>
<?php
$firstLetter = substr($clubs->club_name, 0, 1);
if ($firstLetter != $previousLetter) {
?>
<h3 id="club-link-header"><u><?php echo $firstLetter; ?></u></h3>
<?php } ?>
<a id="club-link" href="<?php echo $this->url(array('controller' => 'club-description', 'action' => 'index', 'club_id' => $clubs->id));?>"><br />
<?php echo $this->escape($clubs->club_name);?></a>
<?php $previousLetter = $firstLetter; ?>
<?php endforeach; ?>
Thanks
You can try the following code . I hope you can understand it.