SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Madison, WI USA
    0 Post(s)
    0 Thread(s)

    structure and stament for stats

    I need to build a very simple stats engine for contests that I make. Right now I store information from contests in a table. I can easily find out how many people entered the contest.

    However, what would also be neat is to track how many people viewed the contest. So, I thought I would put a php tag on the main page of the contest and it would add a number to the database.

    So far, I believe that I need to make a seperate table: Count. The INT collumns for count would be the names of the contest. Each collum would be numerical.

    So, here is where I am stuck. How would I add a number to the the collumn in question? Is there and ADD function in Mysql? Do I need to query the database with PHP, add a number, then update the new number?

    Or, am I going about this the wrong way?

    Table Count
    |contest 1|Contest 2| COntest 3 ...

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Toronto, Canada
    63 Post(s)
    3 Thread(s)
    Quote Originally Posted by webgodjj
    Do I need to query the database with PHP, add a number, then update the new number?
    no, that's not necessary

    just increment the count directly in the table

    update tablename
       set contestNcount = contestNcount + 1
    update tablename
       set contestcount = contestcount + 1
     where contestno = N | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts