Jump to content

[SOLVED] An odd situation/problem


keldek

Recommended Posts

Hello, I'm working on creating a gallery for my site, and have run into a small issue that I cannot seem to resolve.

 

First, my code:

 

<?php if ($this->displayimagecategories == 1)
{
echo '<table border="0">';
echo '<tr>';
foreach ( $this->categories as $category )
{
	echo '<td width="20%" align="center"><a href="'.$category->link.'">'.JHTML::_( 'image.site', $category->linkthumbnailpath, '', '', '', $category->title, 'style="border:0"' ).'</a>';
	echo '<br><a href="'.$category->link.'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'.$category->title.'</a> ';
	echo '<br><span class="small">('.$category->numlinks.')</span></td>';
echo '</tr>';
}
echo '</table>';
}
else
{
?>

 

This works perfect for what I need it to do, except that I need to add some form of if statement that will count how many <td> tags there are, and if the <td> tag count = 5, it'll close the open <tr> and create a new <tr>.

 

If anyone could provide some insight on this issue, I would greatly appreciate the help.

 

Thanks in advance for your help and time.

Link to comment
https://forums.phpfreaks.com/topic/82478-solved-an-odd-situationproblem/
Share on other sites

something like this should work..

 

<?php if ($this->displayimagecategories == 1)
{
echo '<table border="0">';
echo '<tr>';
$intCounter = 0;
foreach ( $this->categories as $category )
{
	$intCounter++;
	echo '<td width="20%" align="center"><a href="'.$category->link.'">'.JHTML::_( 'image.site', $category->linkthumbnailpath, '', '', '', $category->title, 'style="border:0"' ).'</a>';
	echo '<br><a href="'.$category->link.'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'.$category->title.'</a> ';
	echo '<br><span class="small">('.$category->numlinks.')</span></td>';
	if (($intCounter%5)==0) {echo "</tr><tr>";}

}
echo '</tr></table>';
}
else
{
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.