php - Get how much users have referred other users in a specific date -


i have had problems quite time now! have "ref" in database shows users have being referred , "varvade_antal" shows how many have recruited. want out users have recruited more 0 given date, long code this:

<?php      $sql = "select * users date >= '2013-03-01' , date < '2013-04-29' + interval 1 day";     $result = mysql_query($sql) or die(mysql_error());      while($row = mysql_fetch_array($result)){       if($row['ref'] == '0') {      } else {      $sd = "select * users id = '{$row['ref']}'";     $df = mysql_query($sd) or die(mysql_error());      while($dfs = mysql_fetch_array($df)){           echo "{$dfs['firstname']}: {$dfs['varvade_antal']} st<br>";      }}} ?> 

now gets out how many instance have recruited shows duplicates of it, this:

johan have recruited 6 person johan have recruited 6 person johan have recruited 6 person johan have recruited 6 person johan have recruited 6 person johan have recruited 6 person

so, when have recruited 6 people print out 6 times! should not so. me?

use query distinct

$sql = "select distinct * users date >= '2013-03-01' , date < '2013-04-29' + interval 1 day"; 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -