Search code examples
phpmysqldreamweaversqldatatypes

Mysql datatype or php code to increment by 1 every time a page in my database loads in a browser


I am trying to use Dreamweaver to build a Lyrics database website. I have a table for the lyrics and I have a column called "views" that I want to increase by 1 every time that particular lyric is viewed in a browser.

How can I accomplish this using mysql? What mysql datatype Or PHP can I use?

Please explain thoroughly because I do not know php or mysql that well, I'm just trying.

Remember I am using Dreamweaver.

Thanks.


Solution

  • Well we would need to see how your PHP and MySQL is laid out to be honest. Do you want someone to just write it for you or do you want to learn?

    The query would be something like this:

    $query = "UPDATE `myviewstable` SET count = count+1 WHERE id = '$id'";
    

    I believe that would work. id is your lyric id and count is your column for keeping track of numbers.