Author Topic: if else in html table ignores else statement  (Read 702 times)

0 Members and 1 Guest are viewing this topic.

Offline newnewbieTopic starter

  • Irregular
  • Posts: 10
    • View Profile
if else in html table ignores else statement
« on: March 18, 2010, 05:22:45 PM »
Hi... 
I am trying to use an html rollover in a nav table which also includes a php if else statement.  If the page is "My Stories", I want the nav button to be grey, if it is on a different page, I want the nav button to be blue.  I have inserted print statements to test this and the php codes is stopping before the "else" statement, so the button is always displayed as grey and apparantly the rest of the if else statement is being ignored.  The button is grey no matter what page it is on. This is just part of the table and I set my variable earlier in the code like this: 

$page_title = "Home" (or whatever page I am on)

Then I start the table...

<?php
// Beginning of if else to set button for Stories

     if($page_title = "My Stories") {
?>
    <img src="../../_img/buttons/gry_Stories.gif" alt="My Stories" border=0>
<?php
    } else {
?>     
 
  <img src="../../_img/buttons/blu_Stories.gif" border="0" alt="Stories" name="bAstories" id="bAstories" onMouseOver="MM_swapImage('bAstories','','/_img/buttons/gry_Stories.gif',1)" onMouseOut="MM_swapImgRestore()"/></a></td>
</tr> 
</table>

</div>
</body>
</html>

<?php
    }
?>

So, it appears that I am doing something wrong jumping in and out of php to html, maybe?
Thaks to everyone for being patient with us newbies!

Offline nafetski

  • Enthusiast
  • Posts: 270
    • View Profile
Re: if else in html table ignores else statement
« Reply #1 on: March 18, 2010, 05:34:34 PM »
Change

     if($page_title = "My Stories") {

to

     if($page_title == "My Stories") {

Dev Environment: Mac - OSX Snow Leopard / Eclipse / Kohana PHP Framework
Job: Sr Software Developer: (Large scale enterprise)
Notice:  Most of my forum posts I write on my iPhone while taking a dump.  This means that I don't test most of my code, and I might sound like I'm impatient...really I'm just busy punching a grumpy
Also: I've hit Google so many times it's asking for a divorce

Offline newnewbieTopic starter

  • Irregular
  • Posts: 10
    • View Profile
Re: if else in html table ignores else statement
« Reply #2 on: March 18, 2010, 05:58:11 PM »
The fixes are always so simple.  The operator often so inept!  I hope I get good at this some day.  Thank you for taking a dump to help me out  ;)