Jump to content

Archived

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

ChambeRFienD

Checking to see if something is a multiple of 25?

Recommended Posts

Hello, I'd like to write a script to only accept numbers that are multiples of 25, starting at 100 and ending at 50,000...

So if they select something lower than 100 they get an error, something higher than 50,000 they get an error, and if they enter something like 101, it will round it to 125.. I'm sure I could do this with a select(), but it would be an extreme pain to do that for every 25 all the way up to 50,000...

To clear things up:

If they enter 101 in the field, it will round it to 125. If they ender 24,142 it will round to 24,150.. Anyone know a way to do this?

Share this post


Link to post
Share on other sites
[code]<?php
if ($thing><100) {
  echo "an error";
} else {
  $newthing = 25*ceil($thing/25); // result
  .... any other code ...
}
?>[/code]

Share this post


Link to post
Share on other sites
[quote author=AndyB link=topic=106144.msg424269#msg424269 date=1156886321]
[code]<?php
if ($thing><100) {
  echo "an error";
} else {
  $newthing = 25*ceil($thing/25); // result
  .... any other code ...
}
?>[/code]
[/quote]

Thanks much!

Share this post


Link to post
Share on other sites

×

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.