Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to access a PHP variable in both CSS and HTML?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #246578
    MTS
    Participant

    Hey!
    I want to create a website that can test your counting pace. I’ll make colored, square div that change color after 10 to 30 seconds when you hover over it, and then you’ll type down how long you think it took in a form to check if you’re right.
    My solution to do this is to create the PHP variable $time = rand(10,30), and in CSS get the div:hover transition-delay to be $time. Then, after the form, I need the same variable for if($_POST[timeguess] = $time) {echo “Correct!”}.
    I have no idea how to access the same variable in both the CSS and HTML. I know this might be more of a PHP-question than a CSS-question, but I’m hoping someone can help! :)

    #246582
    Shikkediel
    Participant

    Why would you need to have access to the CSS for the variable when it is already created with PHP? I’ve read your post several times, not really getting it. Could you post some code?

    Seems a lot easier to do with JS though. And more versatile.

    Edit – a global variable question perhaps?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.