0

Style sheet not linking to PHP page. Have tried everything from adding the meta tags you'll see below, checking file location, but nothing seems to solve the problem.

Here is the profile.php file:

 <?php 
include("includes/header.php");
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"></meta>
<title>My title</title>
<link href="css/style.css" media="screen" rel="stylesheet" type="text/css" />
</head>

<?php

if(isset($_GET['profile_username'])){
    $username = $_GET['profile_username'];
    $user_details_query = mysqli_query($conn, "SELECT * FROM users WHERE username='$username'");
    $user_array = mysqli_fetch_array($user_details_query);

    $num_friends = (substr_count($user_array['friend_array'], ",")) - 1;
}

?>

    <div class="profile_left">
        <img src="<?php echo $user_array['profile_pic']; ?>">
    </div>

    <div class="profile_info">
        <p><?php echo "Posts: " . $user_array['num_posts']; ?></p>
        <p><?php echo "Likes: " . $user_array['num_likes']; ?></p>
        <p><?php echo "Friends: " . $num_friends ?></p>

    <div class="main_column column">
        <?php echo $username; ?> This is a profile page.
    </div>



    </div> <!-- closes wrapper from header.php-->
</body>
</html>

style.css class that should apply:

  .profile_left {
    top: -10px;
    width: 17%;
    max-width: 240px;
    min-width: 130px;
    height: 100%;
    float: left;
    position: relative;
    background-color: #37b0e9;
    border-right: 10px solid #83d6fe;
    color: #cbeaf8;
    margin-right: 20px;
}

File Hierarchy is below:

enter image description here

4
  • 2
    Does the style.css file load into the browser? Are there messages in the console? Commented Jun 13, 2018 at 6:20
  • About the styles; if the image is larger than the div, it will not be cut off. Rather it will overflow out of the div, making it look like the styles are not applied... Commented Jun 13, 2018 at 6:25
  • You are missing an opening <body> tag and also <div class="profile_info"> is not closed in the code you posted. Commented Jun 13, 2018 at 7:26
  • I am worried about your comment closes wrapper from header.php, which makes it sound like there's a <div> at the very top of the file, before <!DOCTYPE HTML>. This would make much of the document invalid HTML. Commented Jun 17, 2018 at 9:14

1 Answer 1

1

Try the below code

<link href="/css/style.css" media="screen" rel="stylesheet" type="text/css" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.