Page 1 of 1

Array Looping Issue

Posted: Thu Feb 12, 2004 10:27 pm
by Saethyr
God im brain damaged this week.

how would I got about creating check boxes for each element in an array that only goes 4 across then goes to the next line. For example consider the following, if an array had 9 values defined:

Code: Select all

Checkbox1   Checkbox2   Checkbox3   Checkbox4

Checkbox5   Checkbox6   Checkbox7   Checkbox8

Checkbox9


the code will need to do this no matter how many elements the array has.

I am using this as an autoformat and I cannot figure out for the life of me how to make it work.

Posted: Fri Feb 13, 2004 8:47 am
by tsg

Code: Select all

<?
$perRow = 4;
$x = 1;
print "<table><tr>";
	
	while (what i am doing){

		print "print my checkbox";

		if ($x%$perRow) {
		echo "</td>";
		$x++;
		} else {
		echo "</td></tr><tr>";
		$x = 1;
		}
	}
print "</table>"; 

?>
try something like that.

Tim