Click to See Complete Forum and Search --> : table from array


rodesignweb
September 8th, 2008, 08:40 AM
Hello,

I have an array and a variable where I count the number of records from that array. How can I build a dynamic table (not a mysql table) starting from this variable?

For sample:

if my variable has the value 5 I need it to generate a table with 5+1 rows and 4 colums

Please advice. Thank you!

olivthill
September 8th, 2008, 09:31 AM
echo "<table>"
for ($i_line=0; $i_line < $var + 1; $i_line++) {
echo "<tr>"
for ($i_col=0; $i_col < $var - 1; $i_col++) {
echo "<td>"
echo "cell ".$i_line.", ".$i_col."."
echo "</td>"
}
echo "</tr>"
}
echo "</table>"