how can i do this using php?

  • Thread starter Thread starter Natalya
  • Start date Start date
N

Natalya

Guest
i'm a newbie about the php stuff and i wanted to learn this language.
so, i must create a php program in which the data is supplied through an associative array and looped by foreach.
And then I must display it in tabular form like in html table.
How do i do this?
Please help!...
 
http://us.php.net/manual/en/language.types.array.php

http://us.php.net/manual/en/control-structures.foreach.php

<?php
$data = new array('room' => 'kitchen', 'width' => 23, 'length' => 45, 'stove' => true);

echo "<table>";
echo "<tr>";
foreach($data as $key => $value) {
echo "<th>$key</th>";
}
echo "</tr>";
echo "<tr>";
foreach($data as $key => $value) {
echo "<td>$value</td>";
}
echo "</tr>";
echo "</table>";
?>
 
go to www.tizag.com

They have great PHP tutorials. Also that sounds a lot like a homework question. You should ask your teacher if you dont understand something.
 
Back
Top