49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<!doctype html>
|
|
<html lang="pl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport"
|
|
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>Z77 - Od mniejszej do większej</title>
|
|
<link rel="stylesheet" href="style.css">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Zadanie Z77</h1>
|
|
<h2>Autor: Jakub Grzegorczyk</h2>
|
|
</header>
|
|
<div class="box">
|
|
<p>Napisz program, który dla podanych liczb całkowitych A i B wyświetla liczby od A do B, gdy A < B, lub od B do A, gdy B < A.</p>
|
|
</div>
|
|
<div class="box">
|
|
<form action="index.php" method="post">
|
|
<fieldset>
|
|
<label for="a">Wprowadź liczbę A:</label>
|
|
<input type="number" name="a" id="a">
|
|
<label for="b">Wprowadź liczbę B:</label>
|
|
<input type="number" name="b" id="b">
|
|
</fieldset>
|
|
<button type="submit">Wyślij</button>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
if (isset($_POST['a']) && isset($_POST['b'])) {
|
|
echo '<div class="box">';
|
|
$a = (int)htmlspecialchars($_POST['a']);
|
|
$b = (int)htmlspecialchars($_POST['b']);
|
|
if ($a < $b) {
|
|
for ($i = $a; $i <= $b; $i++) {
|
|
echo "$i ";
|
|
}
|
|
}
|
|
if ($b < $a) {
|
|
for ($i = $b; $i <= $a; $i++) {
|
|
echo "$i ";
|
|
}
|
|
}
|
|
echo '</div>';
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|