jBooker Posted November 3, 2008 Share Posted November 3, 2008 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. Link to comment https://forums.phpfreaks.com/topic/131137-im-sorry-i-really-dont-know-what-to-put-for-a-subject-please-help/ Share on other sites More sharing options...
div Posted November 3, 2008 Share Posted November 3, 2008 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; } Link to comment https://forums.phpfreaks.com/topic/131137-im-sorry-i-really-dont-know-what-to-put-for-a-subject-please-help/#findComment-680942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.