Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- If (isset($_REQUEST["enviar"]))
- $enviar = $_REQUEST["enviar"];
- else
- $enviar = "";
- if ($enviar=="Enviar") {
- $n = $_REQUEST["n"];
- $n1 = $_REQUEST["n1"];
- $meio=$n1/2+0.5;
- $meio1=$n/2;
- echo"<table bgcolor=green border=1 align=center>";
- for($i=1;$i<=$n;$i++){
- echo"<tr>";
- for($j=1;$j<=$n1;$j++)
- if($j==1 && $i==1 || $i==$n && $j==$n1 || $i==$n && $j==1 || $j==$n1 && $i==1)
- echo"<td width=30 height=30 bgcolor = black></td>";
- elseif ($j==1 || $j==$n1 )
- echo "<td width=30 height=30 bgcolor = red></td>";
- elseif ($i==$n ||$i==1)
- echo "<td width=30 height=30 bgcolor = green></td>";
- elseif ( $j==$meio )
- echo "<td width=30 height=30 bgcolor = red></td>";
- else
- echo"<td width=30 height=30 bgcolor = white></td>";
- echo"</tr>";
- }
- echo "</table>";
- }
- else {
- ?>
- <html>
- <head>
- <title>Exercicio 4</Title>
- </head>
- <body>
- <form name=formulario method=POST action=ex4.php>
- Insira o numero de linhas:
- <input type=text name=n size=10><br>
- Insira o numero de colunas:
- <input type=text name=n1 size=10><br>
- <br>
- <input type=submit name=enviar value=Enviar>
- </form>
- </body>
- </html>
- <?PHP
- }
- ?>
Add Comment
Please, Sign In to add comment