-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.php
49 lines (38 loc) · 1.05 KB
/
2.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
<?php
include("menu.php");
if(isset($_POST['go'])){
$angka = $_POST['angka'];
$bil = $_POST['bilangan'];
if($bil=="cacah"){
echo "<p> {$angka} bilangan cacah :<br />";
for($i=0;$i<$angka;$i++){
echo $i."<br />";
}
}//cacah
if ($bil=="genap") {
echo "<p> {$angka} bilangan genap :<br />";
for($i=0;$i<$angka;$i++){
echo ($i*2)."<br />";
}
}//genap
if ($bil=="ganjil") {
echo "<p> {$angka} bilangan ganjil :<br />";
for($i=1;$i<=$angka;$i++){
echo ($i*2-1)."<br />";
}
}//ganjil
}
?>
<p>
<form method="post">
<input name="angka" type="number" value="<?php if(isset($angka)) echo $angka;?>" required>
<select name="bilangan">
<option value="cacah" <?php if(isset($bil) && ($bil=="cacah")) echo "selected"; ?>>cacah</option>
<option value="ganjil" <?php if(isset($bil) && ($bil=="ganjil")) echo "selected"; ?>>ganjil</option>
<option value="genap" <?php if(isset($bil) && ($bil=="genap")) echo "selected"; ?>>genap</option>
</select>
<button name="go">go</button>
</form>
<?php
include("menu.php");
?>