473,473 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

choosing a greater number between 2 numbers

2 New Member
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
4 11617
rcmatt4321
25 New Member
Im working on it right now!
May 18 '07 #2
rcmatt4321
25 New Member
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
5,821 Recognized Expert Expert
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
rcmatt4321
25 New Member
That was stupid! :)

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

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

Similar topics

11
by: hokiegal99 | last post by:
How would I determine if a filename is greater than a certain number of characters and then truncate it to that number? For example a file named XXXXXXXXX.txt would become XXXXXX fname = files...
5
by: Henrik J | last post by:
Hello group..! I have this struct: struct FooData { unsigned short *foolist; int NoOfFoos; }; I want to dynamicly allocate X numbers of my FooData struct.
25
by: Jason | last post by:
Hi, below is example code which demonstrates a problem I have encountered. When passing a number to a function I compare it with a string's size and then take certain actions, unfortunately during...
9
by: Martin | last post by:
I am trying to write code that selects a random number in the range 0 to n, where n can be substantially greater than the RAND_MAX on my system which is 32767. I am using VC++ 2003 FWIW. As you...
1
by: trinity | last post by:
Hello all, First, I am grateful for this forum and all comments that will be posted. I am designing a database that compiles data from sewage treatment plants. Mostly the data is numeric. ...
3
by: Massimiliano Alberti | last post by:
Can someone check this? If it's OK, you can use however you want... :-) It should search for an element in an array and, if it can't find it, return the next element. key is what you are...
2
by: Mike | last post by:
Why can I not compare 2 numbers? what i have is this: dim T as string = "101" dim W as string = "99" if T > W then response.write("T is greater") end if
2
by: Stevie | last post by:
Hello I'm trying to work out the regular expression for carrying out a simple 'greater than' comparison. I have a directory with files such as asd345.log, asd346.log, asd347.log and so on.
3
by: Stephen Chaplin | last post by:
I'm summing up time spent on jobs over a week, some of these jobs last greater than 24 hours and when access sums these up it appears that it starts again at 00:00 once it gets past 23:59. Is it...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.