close
<style type="text/css">
<!--
.style1 {font-size: 12px}
.style2 {font-size:16px; color:#FF0000}
-->
</style>
<form method="post">
<span>輸入加總的目標的數字(如從1加到100,就輸入100):</span>
<input type="text" name="number" id="textfield" />
<input type="submit" name="button" id="button" value="加總" />
</form>
<?
$number=isset($_POST['number'])?$_POST['number']:null;
$sum=0;$i=1;
if ($number != null):
do {
$sum=$sum+$i;
$i++;
}
while($i<=$number);
echo "<span>"."本次加總為從 1 加至".$number."</span>";
echo "<span>".",總和為:".$sum."</span>";
endif;
?>
全站熱搜
留言列表