h2 tag not styled wiht div class

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
piano0011
New php-forum User
New php-forum User
Posts: 9
Joined: Mon Mar 19, 2018 4:14 am

Thu Jul 19, 2018 2:27 am

Hey guys!

This is a bit weird because I did manage to get my other h2 tag in my other page to work by doing the following: div.class h2 {} but for some reason, I can't get this to work in my header.php page...

Code: Select all


 <?php
   include_once 'includes/dbh.php';
   $sql = "SELECT * FROM users WHERE user_uid = ?;";

         $stmt = mysqli_stmt_init($conn);

          if (!mysqli_stmt_prepare($stmt, $sql)) {
            header("Location: header.php?index=notexists");
             exit();
          } else {
              mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
              mysqli_stmt_execute($stmt);
              
              $result = mysqli_stmt_get_result($stmt);
           
              
              while ($row = mysqli_fetch_assoc($result)) {

                $sql2 = "SELECT * FROM memberships WHERE user_uid = ?;";
                
                $stmt = mysqli_stmt_init($conn);

                if (!mysqli_stmt_prepare($stmt, $sql2)) {
                  header("Location: header.php?index=notexists");
                   exit();
                } else {
                    mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
                    mysqli_stmt_execute($stmt);

                    $result = mysqli_stmt_get_result($stmt);
                    while($row2 = mysqli_fetch_assoc($result)) {

               echo '<div class="heading">';
               echo '<br></br>';
               echo '<br></br>';
               echo '<h1>Welcome to PianoCourse101: '.$row['user_first'].' '.$row['user_last'].'!</h1>';
              
               echo '<br></br>';
               echo '<h2>Below are your general information. Please feel free to update them in the update section</h2>';
               echo '<br></br>';
               echo '<h2>Email Address: '.$row['user_email'].'</h2>';
               echo '<br></br>';
               echo '<h2>User Permission: '.$row['user_permission'].'</h2>';
               echo '<br></br>';
               echo '<h2>Lesson Subscriptionplan: '.$row2['subscriptionplan'].', '.$row2['subscriptionplan2'].', '.$row2['subscriptionplan3'].'</h2>';
               echo '<br></br>';
               echo '<h2>Date of Subscription: '.$row['datejoined'].'</h2>';
               echo '<br></br>';
               echo '<h2>Last Login: '.$row['user_session'].'</h2>';
               echo '<br></br>';
               echo '</div>';

This is my Css code:

div.title h1{
   position: absolute;
   left: 700px;
   top: 700px;
   
   line-height: 100px;

   font-family: 'Aldrich', sans-serif;
   font-family: 'Mr Dafoe', cursive ;
   font-size: 50px;
}

div.heading h2{
    text-align: center;
}






I got my div.title h1{} to work but not my div.heading h2{} as shown below:
header.PNG
header.PNG (114.41 KiB) Viewed 94 times
p.s. Can we copy and paste the snipping tool here or do we have to use attach file? I can't copy and paste it..

grNadpa
New php-forum User
New php-forum User
Posts: 24
Joined: Fri Dec 02, 2016 8:32 am

Sun Jul 29, 2018 4:24 pm

Is this an excerpt of your code? If not, I don't see the html doctype , html, head and body tags so I am not aware of this particular approach to php / html coding (which is a distinct possibility).

Also, dots/periods within css are to specify that the styles named are for an element identified as a "class", as opposed to "id" not as an element qualifier.

With that, then, the styling I would try drops the "div." prefix before the h1 and h2 thusly:

Code: Select all

 h1{
   position: absolute;
   left: 700px;
   top: 700px;
   
   line-height: 100px;

   font-family: 'Aldrich', sans-serif;
   font-family: 'Mr Dafoe', cursive ;
   font-size: 50px;
}

h2{
    text-align: center;
}
or, if you want to limit your this styling solely to the header class

Code: Select all

.heading h1 { ... }
.heading h2 {... }
See if that works for you.

(You might also want to explore alternatives to relying exclusively on echo for rendering your html).

Post Reply