基礎から解る!PHP入門講座 プログラム入門に最適な言語、PHPを学ぼう

基礎から解る!PHP入門講座

プログラム入門に最適な言語、PHPを学ぼう      

    制御構造ループ 5−1

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html lang="ja"><head>
    <meta http-equiv="Content-type" content="text/html; charset=EUC-JP">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <link rel="stylesheet" href="./style.css">
    <title>いくつでもどうぞ</title></head>
    <body><div class="file2">
    <form action="05_01_loop.php" method="post">
    お好きなものを何個でもどうぞ<br />
    <input type="radio" name="order" value="pizza" />ピザ
    <input type="radio" name="order" value="barger" />ハンバーガー
    <input type="radio" name="order" value="hotdog" />ホットドッグ
    <input type="text" name="num" size="10">
    <input type="submit" value="注文!"></form>
    <!--ここからPHPの始まりです。//-->
    <?php
    error_reporting(1);
    $order = $_POST['order'];
    $num = $_POST['num'];
    $num = htmlspecialchars($num, ENT_QUOTES);  /*タグを無効化 */
    if($order == "pizza") {
        $pict = "<img src='img/pizza.gif'>";
    } else if ($order == "barger") {
        $pict = "<img src='img/humbarger.gif'>";
    } else if ($order == "hotdog") {
        $pict = "<img src='img/hotdog.gif'>";
    } else {
    }
    if($num >=1 and $num <= 100){
      echo "どうぞ!!<br />";
        $a = 0;
        while($a < $num) {
         echo $pict;
         $a++;
        }
    } else if ($num > 100) {
      echo "やっぱりだめ!$num 個なんて多すぎ!1個だけあげる。<br />";
    echo $pict;
    } else {
    }
    ?>

    <!--これでPHPは終わりです。//-->
    </div></body></html>
    2024/3
    SUN MON TUE WED THU FRI SAT
              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       


     フォクすけ©2006 Mozilla Japan



    制作:基礎から解るPHP入門講座 代表:FREEZE

    Copyright © 2005/2/28 flzPHP.All Rights Riserved