Construire tableau HTML
Vous allez construire un tableau HTML à partir d'un script PHP.
Il s'agit de construire la table de multiplication suivante :
| X |
1 |
2 |
3 |
4 |
| 1 |
1 |
2 |
3 |
4 |
| 2 |
2 |
4 |
6 |
8 |
| 3 |
3 |
6 |
9 |
12 |
| 4 |
4 |
8 |
12 |
16 |
Page PHP
<html>
<head>
<title>construire un tableau</title>
</head>
<body>
<h1>construire un tableau</h1>
<?php
echo "<table border=1>\n";
echo "<tr><th>X</th>";
for($j=1;$j<5;$j=$j+1)
{
echo "<th>$j</th>";
}
echo "</tr>\n";
for($i=1;$i<5;$i=$i+1)
{
echo "<tr>";
echo "<th>$i</th>";
for($j=1;$j<5;$j=$j+1)
{
echo "<td>".($i*$j)."</td>";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
</body>
</html>
Résultat HTML
<html>
<head>
<title>construire un tableau</title>
</head>
<body>
<h1>construire un tableau</h1>
<table border=1>
<tr><th>X</th><th>1</th><th>2</th><th>3</th><th>4</th></tr>
<tr><th>1</th><td>1</td><td>2</td><td>3</td><td>4</td></tr>
<tr><th>2</th><td>2</td><td>4</td><td>6</td><td>8</td></tr>
<tr><th>3</th><td>3</td><td>6</td><td>9</td><td>12</td></tr>
<tr><th>4</th><td>4</td><td>8</td><td>12</td><td>16</td></tr>
</table>
</body>
</html>
| Page |
Description |
Dernière mise à jour |
|
| Construire tableau HTML |
un script PHP pour construire un tableau HTML |
24 jan 2008 18:29:40 |
|
Cette page a été générée le 07 oct 2008 14:46:23.
|