how do i do a table pyramid?

e.g.


1st column(1 row), 2nd column(2rows), 3rd column(3rows)

<?php
	$rows=5;
	print "<table border=0>";
	for($i=0;$i<$rows;$i++)
	{
		print "<tr>";
		for ($j=0;$j<=$i;$j++)
		{
			print "<td >".$i*$j."</td>"	;
		}
		print "<tr>";
	}
?>
Member Avatar for rajarajan2017

The above code shows the right angle traingle

Member Avatar for rajarajan2017

Pyramid:

<?php
	$rows=10;
	for ($i = 1; $i <= $rows; $i++) {
		for ($j = $i; $j <= $rows - i; $j++){
			echo "&nbsp;";
		}
		for ($k = 1; $k <= $i; $k++) {
			echo $k . "&nbsp;";
		}
		echo "<br/>";
	}
	
?>

The above code have some limitations too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.