Solved

# Function to calculate value

Posted on 2009-05-07
301 Views
Hi all, I need to create a function that will do the following:
receive a value of a variable, and depending on the value of this variable assign to another variable another value. The range is up to 105 from 1, so to create a switch would be kind of long, if someone have another way to do this would be appreciated.
``````switch (\$variableReceived)

{

case 105:

\$var1 = 105;

\$varNormal = 35;

break;

case 104:

\$var1 = 104;

\$varNormal = 30;

break;

...
``````
0
Question by:doRodrigo
• 2

LVL 142

Expert Comment

what is the logic from the values function?
0

Author Comment

Well the value function should receive a value, like:

values(\$variable);

And receiving this \$variable should be used to know what is the correspondent value, something like:

//values(100);
switch (\$stat) //where stat would be 100
{
case 100:
\$var1 = 100;
\$varNormal = 35;
break;

So the \$var1 would have the same value as the one passed, the \$varNormal would now receive the corresponding value to the value 100.

Did you understand it angelIII?
0

LVL 6

Accepted Solution

mmarth earned 500 total points
switch looks good unless there is a mathematical correlation or unless you want to to change the values. if the valus are going to change it would be better to use a database to get the info so you don't have to change the program.
0

LVL 142

Expert Comment

sorry, but I still don't understand the "problem" :(
0

## Featured Post

### Suggested Solutions

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.