Jump to content

I'm sorry, I really dont know what to put for a subject.. Please help?


jBooker

Recommended Posts

Ok, I'm making a script for users to add stat points to 4 different stats using their unused statpoints.

Now the problem, is complicated..

 

The page is setup like so:

[text area] Strength: $str

[text area] Stamina: $sta

[text area] Dexitery: $dex

[text area] Intellegence: $int

Unused Stat Points: $statpoints

[submit button]

 

The submit button will add the number the user puts in the text area to that stat and then subtract the number from $statpoints. Ok... now the problem;

I need an easy way to make sure the users can not add more then $statpoints, for all the possible combinations. Like say the user put the number 15 into the text area next to $int and puts 12 into the text area next to $dex but only has 17 $statpoints i need it to say "no" and not add the points.

 

Is there a way to do this without to much coding? The only way I can think of doing it is but conbining them all using isset($_POST[""]) and then adding them and checking them against $statpoints but there are just waaaay to many combinations to do all that, or is there?  ???

 

I hope this was not to confusing.

You could try adding the total statpoints together (the total that they have allocated) and then have an IF function stating if their entered points is greater than the unused statpoints, print the "no" and exit. Would be fairly simple to do it that way.

 

Maybe (fields being the boxes where they can enter the numbers):

 

$total=$field1+$field2+$field3+$field4;

 

if($total > $statpoints){

print "Not enough unused statpoints."

exit;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.