very basic if statement, else does not seem to be working.


I have been having a tough time with this little easy script, I hope someone here can show me the error of my ways. Im working with a mod called EZrealty for Joomla. the website is When a property is selected there is an option near the bottom to print page, basically opens a new window without all the fluff. i want this condenced and since the layout has only 1

I thought adding another per row would be the best way. the issue is that not all features are used for each property so lets say…

property 1 has an entry for: lights, ceptic, taxes, bedrooms

I could hard code that so they would display like this

lights | ceptic
taxes | bedrooms

the problem comes in with property 2 if it doesnt have anything for ceptic. the if statement in use doesnt allow ceptic to print since no data is found in the DB so at the least there would be an empty cell, at worst it would throw the whole table out of whack.

i came up with an idea that i think will work but for some reason the code will not cooperate. I created a variable called $counter and set it to the value of 1.

[code]<?php if( $counter = 1 ){

$counter = 2;  

else {
print "

$counter = 1;
}?> [/code]

I added an echo $counter; to the first 5 features just to see if the numbers are switching properly but the printout shows count = 1 then 2 the next 4 times. So it seems my else is not chaning counter back to 1 nor is it printing the table row tags… I even tried removing the print line so it should just switch from 1 to 2 but unfortunately it fails.

The full code for one of these features looks like this

[code]<?php if ( $row->bedrooms >= 1 ){ ?>

 <?php echo _EZREALTY_DETAILS_BEDROOMS;?> : <?php echo $row->bedrooms; echo $counter;?> <?php if( $counter = 1 ){ $counter = 2; } else { $counter = 1; }?>
											<?php } ?>[/code]

any thoughts??

in PHP [size=99px]= [/size] is the ASSIGNMENT operator
[size=99px]==[/size] is the COMPARISON operator.

Change if( $counter = 1 ){ to if( $counter == 1 ){ and you will be fine

Of course anywhere else you have = instead of == (as a comparison operator) you will need to adjust as well.

Good luck

just added the = and it works perferct. I guess by just jumping into web design i missed the basics.

Problem solved, thanks for the help =)

Sponsor our Newsletter | Privacy Policy | Terms of Service