• Resolved danielm04

    (@danielm04)


    hello, i want to execute an if statement but i want that the statemtent executes a css code and not a php code, the part of the code i have to execute inside the statement is this:

    <body 
    style="text-align:center">
     <div class="popup11" onclick="myFunction11()"><i class='fas fa-star' style='font-size:48px;color:yellow'></i>
      <span class="popuptext11" id="myPopup11">
      <?php echo $spp->current()?><br></span>
    </div>
    </body>
    </html>

    so, i tried the following to put it inside the if statement

    <body 
    style="text-align:center">
    <?php 
    $sample = "<div class="popup11" onclick="myFunction11()"><i class='fas fa-star' style='font-size:48px;color:yellow'></i>"
    $sample1 = "<span class="popuptext11" id="myPopup11">"
    $sample3 = "<?php echo $spp->current()?><br></span>"
    if ($spp != null) {
    echo $sample
    echo $sample1
    echo $sample3
    }
    else {
    return
    }
    ?>
    </div>
    </body>
    </html>

    What would you change here? it would be a huge help

    • This topic was modified 4 years, 5 months ago by danielm04.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Your code is PHP, outputting Javascript with some inline CSS.
    Which part is variable, and what is the condition you want to check?

    Thread Starter danielm04

    (@danielm04)

    @joyously thats just part of the code, the code will make many stars generate and each star will popup and show something that someone wrote when you click on it, so the $spp variable is what the person wrote, it is on php because those things go to a document so i had to use the function seek, the condition is that the $spp cant be null, so the star only appears if the line that star is seeking has something wrote, without that condition there will be stars there but the popup will be empty

    • This reply was modified 4 years, 5 months ago by danielm04.

    It doesn’t look correct to me to have <body> and <html> tags, etc. but just to use your example

    <body style="text-align:center">
    <?php
    if ($spp != null) : ?>
     <div class="popup11" onclick="myFunction11()"><i class='fas fa-star' style='font-size:48px;color:yellow'></i>
      <span class="popuptext11" id="myPopup11">
      <?php echo $spp->current(); ?><br></span>
    </div>
    <?php endif; ?>
    </body>
    </html>

    You can make it a function if you need to do it many times.

    Thread Starter danielm04

    (@danielm04)

    Thanks, I’m going to try that, and the html and body is just because of the previous code.

    Thread Starter danielm04

    (@danielm04)

    it did work, thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘css inside if statement’ is closed to new replies.