Guest User

Untitled

a guest
Jun 24th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?PHP
  2. If (isset($_REQUEST["enviar"]))
  3. $enviar = $_REQUEST["enviar"];
  4. else
  5. $enviar = "";
  6.  
  7. if ($enviar=="Enviar") {
  8. $n = $_REQUEST["n"];
  9. $n1 = $_REQUEST["n1"];
  10. $meio=$n1/2+0.5;
  11. $meio1=$n/2;
  12. echo"<table bgcolor=green border=1 align=center>";
  13. for($i=1;$i<=$n;$i++){
  14. echo"<tr>";
  15. for($j=1;$j<=$n1;$j++)
  16. if($j==1 && $i==1 || $i==$n && $j==$n1 || $i==$n && $j==1 || $j==$n1 && $i==1)
  17. echo"<td width=30 height=30 bgcolor = black></td>";
  18. elseif ($j==1 || $j==$n1 )
  19. echo "<td width=30 height=30 bgcolor = red></td>";
  20. elseif ($i==$n ||$i==1)
  21. echo "<td width=30 height=30 bgcolor = green></td>";
  22. elseif ( $j==$meio )
  23. echo "<td width=30 height=30 bgcolor = red></td>";
  24. else
  25. echo"<td width=30 height=30 bgcolor = white></td>";
  26. echo"</tr>";
  27. }
  28. echo "</table>";
  29. }
  30. else {
  31. ?>
  32. <html>
  33. <head>
  34. <title>Exercicio 4</Title>
  35. </head>
  36.  
  37. <body>
  38. <form name=formulario method=POST action=ex4.php>
  39. Insira o numero de linhas:
  40. <input type=text name=n size=10><br>
  41. Insira o numero de colunas:
  42. <input type=text name=n1 size=10><br>
  43. <br>
  44. <input type=submit name=enviar value=Enviar>
  45. </form>
  46. </body>
  47. </html>
  48. <?PHP
  49. }
  50. ?>
Add Comment
Please, Sign In to add comment