Arranging Images

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Deacon Pie
Forum Newbie
Posts: 1
Joined: Tue Apr 15, 2003 11:07 pm

Arranging Images

Post by Deacon Pie »

I want to arrange images so that I can place two across, and then to the next line. The image information is going to be gathered from a database, and basically I need a new <tr> every two images.

Anyone have any ideas on how to work this one out?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you can use the modulus operator to seperate "even/odd" entries.
e.g.

Code: Select all

<html><body>
	<pre>
<?php
$dummy = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h');
$i = 0;
foreach($dummy as $d)
{
	if ($i++ % 2 == 0)
		echo "--break--\n";
	echo $d, "\n";
}
?>
	</pre>
</body></html>
Post Reply