Page 1 of 1

use PHP result to format table

Posted: Thu Mar 30, 2006 5:17 am
by SuperFly
Hi everyone!
I have to create some kind of dynamic page, logic is next:
i have integer in variable and i need to create certain number of fields based on that int....example
$variable = 6 and I need to have table with 6 fields, 4 in one row and 2 in second....my problem is how to do that, how to get new <tr> when number in bigger than 3....
thanks in advanced

Posted: Thu Mar 30, 2006 5:31 am
by JayBird
to get you started...

Code: Select all

if ($variable > 3) {
   echo "</tr>";
}

Posted: Thu Mar 30, 2006 5:42 am
by SuperFly
lets say i have something like this:

Code: Select all

<table>
<tr>
<?php
	$i = 5;
	for($j = 0; $j<$i; $j++)
	{
		?>

		<td><input type="text" name="somename" value="<?php echo $j; ?>"></td>

		<?php
	}

?>
</tr>
</table>
i need 3 fields pre row....
i need some more help

Posted: Thu Mar 30, 2006 10:10 am
by feyd
read the first to links in Useful Posts.