Jump to content


Photo

Problem with an {if} statement


  • Please log in to reply
1 reply to this topic

#1 dkphp2

dkphp2
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 June 2006 - 11:42 PM

<?php 
    $brokerage = "{listing_field_ListingOfficeID_value}"; 
    if ($brokerage != "999"){ 
        echo "<p>foo</p>"; 
        echo "brokerage=$brokerage"; 
    } else { 
        echo "<p>my broker</p>"; 
        echo "brokerage=$brokerage"; 
    } 
?>

I am trying to get it to work within an Open Realty template and {listing_field_ListingOfficeID_value} is one of the fields you can place on the page within the templating system. It appears to be parsing the PHP, but I can't ever get it to behave like I need it to. I've tried single & double quotes around the $brokerage assignment and comparison in the if statement.

I've tried using == to compare instead of !=. Switching the comparison does switch which code is executed, but the statement never evaluates like I need it to. When it echoes the $brokerage variable to the page, it is always correct...but the comparison does not appear to be correct.

What I am trying to get it to do is check the ListingOfficeID, and if it is not mine then it will display a logo denoting that it is listed by another broker.

Any suggestions for what I am doing wrong?

#2 phpvolution

phpvolution
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 15 June 2006 - 04:54 AM

Edit: actually now that I think about it. At the time of the if-statement comparison, your $brokerage variable is still translated as {listing_field_ListingOfficeID_value}, not a number.

but when you echo it it is then parsed into your ID such as 999. So that is a pretty complex problem, and I'm not sure how you can code a work around for it. I may have to tinker some more to figure that out :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users