choosing a greater number between 2 numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • minsumoosane
    New Member
    • May 2007
    • 2

    choosing a greater number between 2 numbers

    Hello,
    Can anyone help me write a php program that have two numbers as input and then choose the greater number of the two.For example, 2 and 7 and choosing 7 as the greater number Thank you so much.
  • rcmatt4321
    New Member
    • May 2007
    • 25

    #2
    Im working on it right now!

    Comment

    • rcmatt4321
      New Member
      • May 2007
      • 25

      #3
      Here ya go! There are two files to create. One is called greaterNum.htm, the other is called greatestProcess .php. greaterNum.htm is the htm file that has the form to enter the two numbers. It sends the values to greatestProcess .php where it chooses the greatest number by going through an if else statement. Just look at it and if you have any more ?'s on how it works just post again.

      greaterNum.htm

      [HTML]<html>
      <form action = "greatestProces s.php" method = "post">
      Enter your first number!<br />
      <input type = "text" name = "numOne" /><br />
      Enter your second number!<br />
      <input type = "text" name = "numTwo" /><br />
      <input type = "submit">
      </form>

      Your Welcome,
      Matt (A Newb to this form)
      [/HTML]

      greatestProcess .php

      [PHP]<?php
      $one = $_POST['numOne'];
      $two = $_POST['numTwo'];
      $greaterNum = NULL;
      if($one > $two) {
      $greaterNum = $one;
      } else {
      $greaterNum = $two;
      };
      echo $greaterNum;
      ?>[/PHP]

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        You're probably looking for this guy.

        [EDIT: Sorry to take the steam out of your engine there, rcmatt4321. It's a good script, but built-ins are always faster ('cause they're compiled) ~_^]

        Comment

        • rcmatt4321
          New Member
          • May 2007
          • 25

          #5
          That was stupid! :)

          Thanks For Pointing That Out,
          Matt

          Comment

          Working...