Array Looping Issue

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
User avatar
Saethyr
Forum Contributor
Posts: 182
Joined: Thu Sep 25, 2003 9:21 am
Location: Wichita, Kansas USA
Contact:

Array Looping Issue

Post 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.
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

Post 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
Post Reply