Tuesday, October 11, 2011

Largest of three numbers and sum of three number

Code Example

Code for max.html

<html>
<head>
 <title>Maximum</title>
</head>
<body>
 <form action = "e1_registration.php">
 <table align="center" cellspacing="20">
  <tr>
   <td>Enter First Name:</td>
   <td><input type="text" name="firstname"></td>
  </tr>
  <tr>
   <td>Enter Last Name:</td>
   <td><input type="text" name="lastname"></td>
  </tr>
  <tr>
   <td>Phone No.</td>
   <td><input type="text" name="phone"></td>
  </tr>
  <tr>
   <td colspan="2" align = "center"><input type="submit" value="  Submit  "></td>
  </tr>
        </table>
 </form>  
</body>
</html>

Code for max.php


<html>
<body>
<?php
 $num1=$_GET['firstno'];
 $num2=$_GET['secondno'];
 $num3=$_GET['thirdno'];
 echo 'Largest number of '.$num1.', '.$num2.', and '.$num3.'  is : ';
 echo $num1>$num2?($num1>$num3?$num1:$num3):($num2>$num3?$num2:$num3);
 echo '<br>sum of '.$num1.', '.$num2.', and '.$num3.'  is : '.($num1+$num2+$num3);
?>
</body>
</html>

No comments:

Post a Comment