By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

choosing a greater number between 2 numbers

P: 2
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.
May 18 '07 #1
Share this Question
Share on Google+
4 Replies


P: 25
Im working on it right now!
May 18 '07 #2

P: 25
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 = "greatestProcess.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]
May 18 '07 #3

pbmods
Expert 5K+
P: 5,821
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) ~_^]
May 18 '07 #4

P: 25
That was stupid! :)

Thanks For Pointing That Out,
Matt
May 18 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.