Jump to content

PHP if then with a variable in an HTML table


newnewbie

Recommended Posts

I am trying to learn how to use a php variable in an html table.  Somewhere I read that you can "move in and out of" php code in the if else code, since php can only display a variable that is within php code.  My "if else" code is in an html table.  I don't get errors, but the button that should be grey (stories) remains blue (and an html rollover).  I want the button to be grey (and only grey) if the page title is "My Stories."  I hope this explains.  I have only included one row of the table.  Haven't dont the rest, 'cause I can't get it right!  Here is my code:

 

<tr>

  <td><a href="file:///C|/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/site/stories.php">

 

<?php

$page_title == "My Stories";

// Beginning of if else to set button

 

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

?>

<img src="../../_img/buttons/gry_Stories.gif" alt="My Stories">

<?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

}

?>

 

Thanks in advance and pardon my ineptness!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.