how to show top reffere user from mysql...???
Collapse
X
-
if the last 1 is working just get rid of the limit 0, 5;
as u will be only displaying 5 results
Leave a comment:
-
i putted disOriginally posted by something else View Postsomething 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];
}
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/abc/public_html/aaaa.php on line 3PHP 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];
}
?>
after that i putted
butPHP 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];
}
?>
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.
Leave a comment:
-
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];
}
Leave a comment:
-
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 disLast edited by slowy; 12.09.10, 04:24.Tags: None
Leave a comment: