...

View Full Version : Simple Math Problem



Vacendak
08-26-2009, 02:35 AM
I am newbie to php and am trying to resolve a simple math problem. I need to take a number and divide it based on the selection of a drop down box. As an example let's say I have a figure like 1000 and a drop down box that has a list of numbers 1 though 15. I would like like to be able to select a number in the drop down box and hit a submit button and the result would be 1000 divided by the number selected.

seco
08-26-2009, 02:54 AM
<?php
if(isset($_POST['submit'])){

$number = $_POST['number'];

echo 1000/$number;

}
?>


<form action="" method="post">
<select name="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input name="submit" type="submit">
</form>

Vacendak
08-26-2009, 03:57 AM
<?php
if(isset($_POST['submit'])){

$number = $_POST['number'];

echo 1000/$number;

}
?>


<form action="" method="post">
<select name="number">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input name="submit" type="submit">
</form>

Thanks for the perfect prompt response. This has been kicking my butt for 2 days and google just couldn't get done exactly what I wanted to do. You rock.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum