Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

show region if

How do I say. Only show region if $row_WAATKroi['printer'] equals 1 or 2?
0
petewinter
Asked:
petewinter
  • 3
  • 2
  • 2
1 Solution
 
lharrispvCommented:
if ($row_WAATKroi['printer'] ===1  || $row_WAATKroi['printer'] ===2)
//show region code here
;
0
 
petewinterAuthor Commented:
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 ?>
0
 
Ray PaseurCommented:
Not sure why you are using the === construct, so if you do not know why you are testing for equivalence instead of equality, you probably want to use the == construct.

Have you printed out the $row_WAATKroi array with var_dump() to see what the values are for 'printer' in that array?
<?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 
?>
	 

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
petewinterAuthor Commented:
Perfect. Thanks Ray
0
 
lharrispvCommented:
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

0
 
lharrispvCommented:
oh and the reason I had three equals (===) is because it makes a strick comparison...
0
 
Ray PaseurCommented:
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
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now