-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhile.php
159 lines (127 loc) · 4.31 KB
/
while.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html>
<head>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="./css/style.css" rel="stylesheet">
<title>Tabuada</title>
<link rel="shortcut icon" href="./imagens/iconepagina.png" type="image/x-icon">
</head>
<body>
<style>
input[type="submit"] {
padding: 10px 20px;
font-size: 16px;
font-weight: bold;
color: #fff;
background-color: #007BFF;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
input[type="number"] {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
outline: none;
}
input[type="number"]:focus {
border-color: #007BFF;
box-shadow: 0 0 5px #007BFF;
}
a {
text-decoration: none;
}
</style>
<nav class="navbar col-12 m-auto position-fixed navbar-expand-lg navbar-dark bg-info" style="z-index:999;">
<a class="navbar-brand" href="#"> Tabuada </a>
</nav>
<br> <br>
<div class="imagem">
<img src="./imagens/matematica.jpeg" class="imagem" alt="Imagem de fundo cinza" height="500px" width="2266px" >
</div>
<nav class="navbar navbar-expand-lg bg-body-tertiary bg-light">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="./index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./while.php">While</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./dowhile.php">Do while</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./for.php">For</a>
</li>
</ul>
</div>
</div>
</nav>
<br> <br> <br> <center>
<div class="card" style="width: 18rem;">
<div class="card-body">
<h5 class="card-title">Tabuada</h5>
<h6 class="card-subtitle mb-2 text-body-secondary">Laço While </h6>
<p class="card-text">
<form method="post" action="">
💻 Digite um número (1 a 10) ou 0 para todas as tabuadas 💻 <br><br>
<input type="number" name="numero" min="0" max="10" required> <br><br>
<input type="submit" value="Ver Tabuada">
</form>
<br>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$numero = $_POST["numero"];
if ($numero == 0) {
$i = 1;
while ($i <= 10) {
echo "<br>";
echo "<h6> 🧮 Resultado: 🧮 </h6>";
echo "<h3>Tabuada do $i</h3>";
$j = 1;
while ($j <= 10) {
$resultado = $i * $j;
echo "$i x $j = $resultado<br>";
$j++;
}
$i++;
}
} else if ($numero >= 1 && $numero <= 10)
{
echo "<br>";
echo "<h6> 🧮 Resultado: 🧮 </h6>";
echo "<h3> Tabuada do $numero </h3>";
$i = 1;
while ($i <= 10) {
$resultado = $numero * $i;
echo "$numero x $i = $resultado<br>";
$i++;
}
}
else
{
echo "<p>Digite um número entre 1 e 10 ou 0 para todas as tabuadas.</p>";
}
}
?>
</p>
</div>
</div>
<br> <br> <br><br>
<center>
<h1> <span class="texto01"> . </span> <span class="texto02"> ✧ Tabuada em PHP ✧ </span> </h1> <br>
<div class="d-grid gap-2">
<button class="btn btn-primary" type="button"> <a href="./while.php"> Atualizar </a> </button>
</div>
</body>
</html>