How do i, Add Values in MySQL and display them with PHP?

Discussion in 'PHP' started by Ninjasoft, Oct 28, 2008.

  1. #1
    I want to add up all the views for each users profile and display it on the homepage. The Mysql stucture is like this..

    Databasename: msn_Socialsite
    Then the table : Users
    Then the sub table : views

    The views table just has a number in it.


    how would i add all the views togetherer and display on a seprate page with php?


    could someone show me the code? thanks loads!
     
    Ninjasoft, Oct 28, 2008 IP
  2. Sillysoft

    Sillysoft Active Member

    Messages:
    177
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Hmm

    
    $sql = "SELECT *,(SELECT COUNT(*) FROM views WHERE userid = Users.id) AS userviews FROM users ORDER BY userviews DESC
    
    PHP:
    Dont know your fields but this should get u started.
     
    Sillysoft, Oct 29, 2008 IP
  3. Ninjasoft

    Ninjasoft Peon

    Messages:
    338
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks, ill have a go at that, anyone else think they have a solution?
     
    Ninjasoft, Oct 30, 2008 IP
  4. Ninjasoft

    Ninjasoft Peon

    Messages:
    338
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    sillysoft, thanlks for the attempt, but i have no clue how to implement that code you gave me :S it's not a valid php code.
     
    Ninjasoft, Oct 30, 2008 IP