Zahlen ändern im Code ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Zahlen ändern im Code ?

    hi nochmals

    ich habe folgendes script:

    <?
    $zahl = 1000;
    echo "Deine Nummer ist $zahl";
    if ($action == "add")echo "Deine Nummer ist nun $zahl";
    $zahl=$zahl - 100;
    ?>

    <a href="test.php?action=add">Test</a>

    Warum wird die 100 nicht abgezogen?

    Mfg

  • #2
    versuche es mal so:

    PHP Code:
    <?
    $zahl="1000";
    echo "Deine Nummer ist $zahl";
        if($action=="add")
           {
                $zahl=("$zahl" - "100");           
                echo "Deine Nummer ist nun $zahl";
           }
    ?>

    <a href="test.php?action=add">Test</a>
    Mit freundlichen Grüßen
    Werner

    Comment


    • #3
      weil du erst den startwert ausgibst, und dann davon was abziehst

      @novara
      rechnen mit strings
      Kissolino.com

      Comment


      • #4
        loel
        verantwortlich für Elygor - Das kostenlose Browserspiel

        Comment


        • #5
          Original geschrieben von sEeb
          loel
          OffTopic:
          und wo ist jetzt hier die stelle zum lachen?
          Kissolino.com

          Comment


          • #6
            nimm lieber mal $_GET['action']
            Beantworte nie Threads mit mehr als 15 followups...
            Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25

            Comment


            • #7
              mach mal so:
              PHP Code:
              $action $_GET['action'];
              $zahl 1000;
              if(!isset(
              $action))
              {
              print 
              $zahl;
              }
              elseif(isset(
              $action) AND $action == "add")
              {
              $zahl $zahl 100;
              print 
              $zahl;

              Comment


              • #8
                man sollte lieber $_GET['action'] mit isset prüfen...
                Beantworte nie Threads mit mehr als 15 followups...
                Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25

                Comment


                • #9
                  Original geschrieben von MelloPie
                  man sollte lieber $_GET['action'] mit isset prüfen...
                  OffTopic:
                  irgendwie kommst du mir heute vor, wie der "ungehörte rufer in der wüste" ... nehmt $_GET, nehmt $_GET, nehmt $_GET ...
                  Kissolino.com

                  Comment

                  Working...
                  X