0

All arguments aside from using $html->tag() instead of <tag> ...

I'm a trying to create a table to display photos I'm pulling from the database and something is amiss.

When I was testing this I changed $num_cols to 2 and it ended the row and started a new one after the second col like I expected. I must have inadvertently changed something because now it won't break on the col like I want it to. Any help would be appreciated.

$i = 0; 
$k = 0;
$num_of_cols = 5; 
echo 
$html->tag('table', null, array(
			        'cellspacing' => 0,
				'cellpadding' => 0,
				'border' => 0
				)
	  )
.$html->tag('tr');

echo ($i!= 0 && $i%$num_of_cols == 0)?'</tr><tr>':'';

foreach($photos as $photo)
{
echo $html->tag('td', null, array(
				  'valign' => 'top'
				  )
		)
.$html->tag('img', null, array(
				'src' => Router::url(array(
							   'controller' => 'photos',
							   'action' => 'displayPhotos/'.$photos[$k++]['Photo']['id']
							   )
			                              ),
							   'height' => 90
				)
	   )
.$html->tag('/td');
$i++; 
}

echo $html->tag('/tr')
.$html->tag('/table');
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by CFROG
0

I got it ... :)

this should be inside the loop, duh. echo ($i!= 0 && $i%$num_of_cols == 0)?'</tr><tr>':'';

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.