<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;
if ($number != null):
$sum=0;
for ($i=1;$i<=$number;$i++){
$sum=$sum+$i;
};
echo "<span>"."本次加總為從 1 加至".$number."</span>";
echo "<span>".",總和為:".$sum."</span>";
endif;
?>

範例網頁

arrow
arrow
    全站熱搜

    ALVIN 發表在 痞客邦 留言(0) 人氣()