if ($r["afisha_prem"] == 1) { $prem = '<span style="font-style:italic">Премьера!</span><br />'; } else { $prem = ''; } (???) <!--if (date("l",$r["afisha_date"])=="Saturday") {$date = 'color="#ff0064'}-->(???) 

If in the database we have a poster = 1, then we deduce the prime minister, otherwise it is empty. And how to do if the day off, the text color is yellow?

    3 answers 3

     <span style="<?php echo 'color: yellow;';?>font-style:italic">Премьера!</span> 

    You can substitute a variable if necessary.

     <span style="<?php echo $date;?>font-style:italic">Премьера!</span> 

    With the condition:

     if ($r["afisha_prem"] == 1) { $prem = '<span style="font-style:italic">Премьера!</span><br />'; } elseif (($r["afisha_date"] == "Saturday") == (date("l") == "Saturday")) { $prem = '<span style="font-style:italic; color: yellow;">Премьера!</span><br />'; echo $prem; } 
    • But how to do if the "day off" then the text color is yellow ???? - psix
    • write if it's not difficult)) - psix
    • At @Palmervan probably the idea is fixed. As I see, there are already a lot of solutions, so try it and you will succeed. - Artyomich
    • @Palmervan use date () function; instead of time (); as time Returns the number of seconds elapsed from the beginning of the Unix Epoch (The Unix Epoch, January 1, 1970, 00:00:00 GMT) to the current time. - Artyomich
    • The @archi_sova in the question clearly states that - if in DB 1, then we display a poster, and if it is also a weekend, then paint it! In your $r["afisha_date"] variable takes the value of the day of the week and not the result stored in the database! In essence, it should be, и, или combination! - Palmervan

    date

      Code in your style ...

       if(date("N", time()) == '6' or date("N", time()) == '7') { $paint = ' color: #ff0000'; } else { $paint = ''; } if($r["afisha_prem"] == 1) { $prem = '<span style="font-style:italic; '.$paint.'">Премьера!</span><br />'; } else { $prem = ''; } echo $prem; 
      • strangely yellow does not write (( - psix
      • @step put instead of 6 or 7 - 2, and will write! - Palmervan
      • no (as it was written in white and spelled, even today's date is not written in yellow. - psix
      • @step screen send?))) - Palmervan
      • All)))) people litter, I didn’t do it, I’m just a code of rules))) there was no date at all, they hammered it in with their hands, so they didn’t see our code or date))))) everything works, set in the date item bd, everything works fine. thank! - psix