how to show top reffere user from mysql...???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    how to show top reffere user from mysql...???

    hi, guys
    i want to show the top 5 refferer user from my sql table.
    table has following thing.
    database name- users
    total table-3
    table name-id,ref,name
    here:
    id=user id
    ref=the user id of that user who is reffered this user
    name=username


    following is the entry in above 3 tables
    1,0,abc
    2,1,def
    3,1,ghi
    4,2,jkl
    5,1,mno
    6,2,pqr
    7,1,stv
    8,5,uwx
    9,8,xyz
    10,8,aaa

    according to above table i want to show this
    abc=4
    def=2
    uwx=2
    mno=1


    plz help in dis
    Last edited by slowy; 12.09.10, 04:24.

    http://WapTops.com- Get Real High Traffic
    http://WapFun.info-Fun 4 Wap

    #2
    something on the lines of:
    PHP Code:
    $sql mysql_query"SELECT name, COUNT(ref) AS NumOccurrences FROM users GROUP BY ref HAVING (COUNT(ref)>0)");
    while(
    $list mysql_fetch_array($sql)){
    echo 
    $list[0].'='.$list[1];

    Comment


      #3
      Originally posted by something else View Post
      something on the lines of:
      PHP Code:
      $sql mysql_query"SELECT name, COUNT(ref) AS NumOccurrences FROM users GROUP BY ref HAVING (COUNT(ref)>0)");
      while(
      $list mysql_fetch_array($sql)){
      echo 
      $list[0].'='.$list[1];

      i putted dis

      PHP Code:
      <?php 
      include ("header.php");
      $sql mysql_query'SELECT 'name',COUNT(ref) AS NumOccurrences FROM 'users' GROUP BY 'ref' HAVING (COUNT(ref)>0)';
      while(
      $list mysql_fetch_array($sql)){
      echo 
      $list[0].'='.$list[1];
      }
      ?>
      Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/abc/public_html/aaaa.php on line 3


      after that i putted
      PHP Code:
      <?php 
      include ("header.php");
      $sql "SELECT name, COUNT(ref) AS NumOccurref FROM users GROUP BY ref HAVING (COUNT(ref)>0)";
      while(
      $list mysql_fetch_array($sql)){
      echo 
      $list[0].'='.$list[1];
      }
      ?>
      but
      Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/abc/public_html/aaaa.php on line 4

      Added after 33 minutes:

      now i putted
      dis,every thing is fine but not giving data what i want

      PHP Code:
      <?php 
      include ("header.php");
      $sql "SELECT name, COUNT(ref) AS NumOccurrences FROM users GROUP BY ref HAVING (COUNT(ref)>0) LIMIT 0, 5;";
      $sites=MySQL_Query($sql);
      while(
      $list mysql_fetch_array($sites))
      {
      echo 
      $list[0].'='.$list[1];
      echo 
      "<br />";
      }
      ?>
      Last edited by slowy; 12.09.10, 06:27.

      http://WapTops.com- Get Real High Traffic
      http://WapFun.info-Fun 4 Wap

      Comment


        #4
        if the last 1 is working just get rid of the limit 0, 5;
        as u will be only displaying 5 results

        Comment


          #5
          SELECT field FROM table ORDER BY field DESC and put it on while loop.
          Nous Ne Dansos Pas, Nous Sommes Le Danse.!

          Comment

          Working...
          X