use PHP result to format table

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
SuperFly
Forum Newbie
Posts: 19
Joined: Thu Nov 10, 2005 9:47 am
Contact:

use PHP result to format table

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

to get you started...

Code: Select all

if ($variable > 3) {
   echo "</tr>";
}
SuperFly
Forum Newbie
Posts: 19
Joined: Thu Nov 10, 2005 9:47 am
Contact:

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

read the first to links in Useful Posts.
Post Reply