counting number of unique entries under a column

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mr_burns

    counting number of unique entries under a column

    hi,
    i am wanting to count the number of unique rows under a certain
    column. i want to count how many times a page has been accessed. how i
    plan to do this is every time a page is accessed, a session id
    variable is checked for. if noe exist, a piece of code will create on.
    then the session id is store in a table under one column and the pages
    pre-defined number will be stored under another. so if i want to check
    how many users have access a page in seperate sessions, all i need to
    do is count how many unique session ids exist for that page (using the
    page number - i.e. SELECT ... WHERE page_id = 8).

    as i mentioned, i dont know how to count how many unique entries their
    are under a column. any ideas??

    also, how is it i check if a variable exists??

    cheers

    burnsy
  • Tom Thackrey

    #2
    Re: counting number of unique entries under a column


    On 8-Oct-2003, bissatch@yahoo. co.uk (mr_burns) wrote:
    [color=blue]
    > i am wanting to count the number of unique rows under a certain
    > column. i want to count how many times a page has been accessed. how i
    > plan to do this is every time a page is accessed, a session id
    > variable is checked for. if noe exist, a piece of code will create on.
    > then the session id is store in a table under one column and the pages
    > pre-defined number will be stored under another. so if i want to check
    > how many users have access a page in seperate sessions, all i need to
    > do is count how many unique session ids exist for that page (using the
    > page number - i.e. SELECT ... WHERE page_id = 8).
    >
    > as i mentioned, i dont know how to count how many unique entries their
    > are under a column. any ideas??[/color]

    assuming mysql:
    $rs = mysql_query("se lect distinct columnname from tablename where
    page_id=8") or die(mysql_error ());
    $num_rows = mysql_num_rows( $rs);
    [color=blue]
    >
    > also, how is it i check if a variable exists??[/color]

    if (isset($variabl ename))
    // $variablename exists
    else
    // it doesn't

    --
    Tom Thackrey

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    • Andy Hassall

      #3
      Re: counting number of unique entries under a column

      On 8 Oct 2003 17:09:48 -0700, bissatch@yahoo. co.uk (mr_burns) wrote:
      [color=blue]
      >i am wanting to count the number of unique rows under a certain
      >column. i want to count how many times a page has been accessed. how i
      >plan to do this is every time a page is accessed, a session id
      >variable is checked for. if noe exist, a piece of code will create on.
      >then the session id is store in a table under one column and the pages
      >pre-defined number will be stored under another. so if i want to check
      >how many users have access a page in seperate sessions, all i need to
      >do is count how many unique session ids exist for that page (using the
      >page number - i.e. SELECT ... WHERE page_id = 8).
      >
      >as i mentioned, i dont know how to count how many unique entries their
      >are under a column. any ideas??[/color]

      SELECT COUNT(DISTINCT whatever)
      FROM ...
      [color=blue]
      >also, how is it i check if a variable exists??[/color]



      --
      Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
      Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

      Comment

      Working...