Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-26-2009, 01:35 AM   PM User | #1
Vacendak
New to the CF scene

 
Join Date: Aug 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Vacendak is an unknown quantity at this point
Simple Math Problem

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.
Vacendak is offline   Reply With Quote
Old 08-26-2009, 01:54 AM   PM User | #2
seco
Regular Coder

 
seco's Avatar
 
Join Date: Nov 2008
Location: Oregon
Posts: 682
Thanks: 5
Thanked 79 Times in 77 Posts
seco has a little shameless behaviour in the past
PHP Code:
<?php
if(isset($_POST['submit'])){

$number $_POST['number'];

echo 
1000/$number;

}
?>
Code:
<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>

Last edited by seco; 08-26-2009 at 01:58 AM..
seco is offline   Reply With Quote
Users who have thanked seco for this post:
Vacendak (08-26-2009)
Old 08-26-2009, 02:57 AM   PM User | #3
Vacendak
New to the CF scene

 
Join Date: Aug 2009
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Vacendak is an unknown quantity at this point
Quote:
Originally Posted by seco View Post
PHP Code:
<?php
if(isset($_POST['submit'])){

$number $_POST['number'];

echo 
1000/$number;

}
?>
Code:
<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.
Vacendak is offline   Reply With Quote
Reply

Bookmarks

Tags
math, newbie, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:58 AM.


Advertisement
Log in to turn off these ads.