Jump to content

modal hit counter


Recommended Posts

I'm using the w3.css modal to display videos stored on the local server:

<button onclick="document.getElementById('<?php echo $row['id']; ?>').style.display='block'" class="w3-button w3-black"><i class="far fa-play-circle fa-3x"></i> <?php echo $row['short_description']; ?></button>
                    <div id="<?php echo $row['id']; ?>" class="modal">
                        <div class="modal-content">
                            <div class="w3-container">
                                <span onclick="document.getElementById('<?php echo $row['id']; ?>').style.display='none'" class="w3-button w3-display-topright close">&times;</span>
                                <video controls
                                    src="videos/<?php echo $row['fileName']; ?>" width="200">
                                <p><?php echo $row['description'] ?></p>
                    var modal = document.getElementById('<?php echo $row['id']; ?>');
                    window.onclick = function(event)
                        if (event.target == modal)
                            modal.style.display = "none";

And that is working fine. Now I would like to add a pageHits column to my sql videos table and track the number of hits to each individual video. (I already track the number of hits to the videos page and that works fine.)

I've tried numerous bits of code from numerous website and stackexchange and so far none of them have worked to increase the counter in the database.

What code do I need to add to simply count the hits to the individual video modals?


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...