All the "if else" should be "else if", or evan "elseif" since php has introduced that keyword aswell. If you want to get rid of some if() statements you could also use switch(). It will do the same thing, some people think it looks better some people don't :P
PHP Code:
switch($squarefeet) { case 1500: echo "<p><img src=\"1500.gif\">"; break; case 2000: echo "<p><img src=\"2000.gif\">"; break; case 2500: echo "<p><img src=\"2500.gif\">"; break; case 3000: echo "<p><img src=\"3000.gif\">"; break; case 3500: echo "<p><img src=\"3500.gif\">"; break; case 4000: echo "<p><img src=\"4000.gif\">"; break; }
Or in this case, where the different cases are so similar, you can do like this. Again, it's just a question of which way you like the best, all of them will work.
PHP Code:
$allowed = array(1500, 2000, 2500, 3000, 3500, 4000); $size = in_array($squarefeet, $allowed) ? $squarefeet : 1500; echo "<p><img src=\"$size.gif\">";
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
|