How do I pro-identify that will exceed the count set on the form and pause before?
FORM:
<form method="get" action="exercico04.php">
Inicio: <input type="number" name="inicio" value="1" max="100" min="1"/><br/>
Final: <input type="number" name="final" value="1" max="100" min="1"/><br/>
Incremento:
<select name="incremento">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<br>
<input type="submit" value="Contar" class="botao"/>
PHP:
$inis = isset($_GET["inicio"])?$_GET["inicio"]:0;
$finis = isset($_GET["final"])?$_GET["final"]:0;
$incris = isset($_GET["incremento"])?$_GET["incremento"]:0;
if($inis < $finis){
echo $inis . " ";
while($inis < $finis) {
$inis+=$incris;
echo $inis." ";
}
}else if($inis > $finis){
echo $inis . ",";
while($inis > $finis) {
$inis-=$incris;
echo $inis ." ";
}
}
In the case, for example, if I choose HOME 7, FINAL 45 and INCREMENT 4, it will count as follows: 7 11 15 19 23 27 31 35 39 43 47
Only in case, I want it to stop before reaching 45, which would be in case no 43. How do I do this?