'CSS Styling for HTML inserted inside of php if/else statement not working
I'm writing this code so that one of two different things displays to the user depending on whether or not they are logged. The css worked when I didn't have this section wrapped in an if/else statement. Now that I put it into one, the CSS is refusing to work. Not sure why. I've reviewed the code several times. Even looked at the "page source" after I pushed it online. Everything is structured correctly so I can't figure out why it won't work.
Here is the code that I'm using. I am embedding this code into the homepage using a "require once". I do have it wrapped in tags, this is just the section that doesn't want to work.
Here is the CSS linking. I already tried changing the file that my CSS is in to an absolute link to see if that work work.
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/nav.css" />
<link rel="stylesheet" href="css/blog.css" />
<link rel="stylesheet" href="css/footer.css" />
<link rel="stylesheet" href="css/forms.css" />
Here is my PHP file. Everything was working until I put the HTML into an if/else statement.
if (isset($_SESSION['username']) && isset($_SESSION['user_id'])) {
echo '<section class="topnavbar">';
echo '<div id="top-login">';
echo '<a href="#">Listing Profile</a> / <a href="#">Account Settings</a> / <a href="#">Case Requests</a>';
echo '</div>';
echo '</section>';
} else {
echo '<section class="topnavbar">';
echo '<div id="top-register">';
echo '<a href="#">Client Register</a> / <a href="#">Lister Register</a>';
echo '</div>';
echo '<div id="top-login">';
echo '<a href="#">Client Login</a> / <a href="#">Lister Login</a>';
echo '</div>';
echo '</section>';
}
The odd thing is that the CSS was working perfectly until I put the HTML inside of an if/else statement.
This is how the HTML is outputting in the "source" file.
<section class="topnavbar"><div id="top-register"><a href="#">Client Register</a> / <a href="#">Lister Register</a></div><div id="top-login"><a href="#">Client Login</a> / <a href="#">Lister Login</a></div></section> <section class="header-grid">
Solution 1:[1]
follow this example (add Backslash before double quotes)
echo "<section class=\"topnavbarBackslash\"><h2>hello</h2></section>";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
