Default code
Posted: Thu Oct 29, 2009 2:12 pm
Hi guys
I have a bit of code that defines a default figure if a calculation equals or is less than a certain figure. It works fine in this sens. However, the problem I'm having is that when the calculated figure is greater than 9999 (e.g. 99999) the figure defaults to the default figure. This is unintended and the code as written offers no explanation to me as to why it is doing this.
I was wandering therefore if someone could have a look at it and see what, if anything, is making it do this. Here's the code (it's a pretty simple code).
All and any help greatly appreciated.
Thanks
I have a bit of code that defines a default figure if a calculation equals or is less than a certain figure. It works fine in this sens. However, the problem I'm having is that when the calculated figure is greater than 9999 (e.g. 99999) the figure defaults to the default figure. This is unintended and the code as written offers no explanation to me as to why it is doing this.
I was wandering therefore if someone could have a look at it and see what, if anything, is making it do this. Here's the code (it's a pretty simple code).
Code: Select all
$defprice = 50;
if ($price <=0) {
$price =0;
}
elseif ($price < $defprice) {
$price =$defprice;
}Thanks