Link to home
Start Free TrialLog in
Avatar of Pete Winter
Pete WinterFlag for United Kingdom of Great Britain and Northern Ireland

asked on

show region if

How do I say. Only show region if $row_WAATKroi['printer'] equals 1 or 2?
Avatar of lharrispv
lharrispv
Flag of United States of America image

if ($row_WAATKroi['printer'] ===1  || $row_WAATKroi['printer'] ===2)
//show region code here
;
Avatar of Pete Winter

ASKER

Thanks for the reply, but it's not working. Can you please check my code:

<?php if ($row_WAATKroi['printer'] ===1  || $row_WAATKroi['printer'] ===2) { // Begin Show Region ?>
<li class="t3"><a href="#p7EPMc1_3" id="p7EPMtrg1_3">Rental</a></li>
<?php } // End Show Region ?>
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect. Thanks Ray
try this..

<?php if ($row_WAATKroi['printer'] ==1  || $row_WAATKroi['printer'] ==2)
// Begin Show Region
echo  '<li class="t3"><a href="#p7EPMc1_3" id="p7EPMtrg1_3">Rental</a></li>';
// End Show Region
?>
notice I did two things.  1) rather than breaking out of php I used the echo to write the html to screen and 2 based on the if statement description at w3schools I took the curly brackets out (as was in my original example).

http://www.w3schools.com/php/php_if_else.asp

oh and the reason I had three equals (===) is because it makes a strick comparison...
Thanks for the points.  Almost without exception the form data contains character strings instead of numeric values.  So, for example, a numeric (integer) value 3 is not considered the same as a character string "3" if you use the === operator.  However due to PHP type juggling, the number and character string are considered the same if you use the == operator.

Best regards, ~Ray