kom er niet uit php

Gestart doorDaiman3 reacties23 weergaven

4 berichten · pagina 1 van 1

Daiman

Lid · Topicstarter

Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoi

ik ben bezig met een ref actie script
alleen staat in de tabel "leden" de leden en een veld "ref"
in dat veld komt te staan via wie er aangemeld is

hoe kan ik een top 10 maken?

ik heb ut al :

[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$c[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
  {[/COLOR]
  [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
   [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$a[/COLOR][COLOR= #007700])) {[/COLOR]
  [COLOR= #0000BB]$a[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]];[/COLOR]
  [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;
  }
  }
 
  }[/COLOR]
  [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]AS[/COLOR] [COLOR= #0000BB]$ref[/COLOR][COLOR= #007700]) {[/COLOR]
  [COLOR= #0000BB]$t[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE ref="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ref[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
  [COLOR= #0000BB]$t[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700]);[/COLOR]
  [COLOR= #0000BB]$g[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$ref[/COLOR][COLOR= #007700];[/COLOR]
  [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$g[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] <br>[/COLOR][COLOR= #007700];
  }[/COLOR]

?>


vraag 2 : met de code hier boven staat het niet georderd nu wil ik dus degene met de meeste refs boven aan hebben hoe kan ik dat het beste doen?
0
Tom

Lid

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Zet deze code is neer waar je query nu staat:

mysql_query("SELECT uId,uName,uCoins,uRang,uRangN,uCol,uSite, uIp FROM member_accounts ORDER BY uCoins DESC LIMIT 0,3");


Vervang de namen door jouw gegevens.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is ref een nummer of een naam?
0
Daiman

Lid · Topicstarter

Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@tom : maakte niks uit
@luukvdo :
ik heb ut al wink
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$c[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$lid[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
  {[/COLOR]
  [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700]) {[/COLOR]
   [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][URL="http://www.php.net/in_array"]in_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$a[/COLOR][COLOR= #007700])) {[/COLOR]
  [COLOR= #0000BB]$a[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ref[/COLOR][COLOR= #007700]];[/COLOR]
  [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;
  }
  }
 
  }[/COLOR]
  [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]AS[/COLOR] [COLOR= #0000BB]$ref[/COLOR][COLOR= #007700]) {[/COLOR]
  [COLOR= #0000BB]$t[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM leden WHERE ref="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ref[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
  [COLOR= #0000BB]$t[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700]);[/COLOR]
  [COLOR= #0000BB]$g[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$ref[/COLOR][COLOR= #007700];[/COLOR]
  [COLOR= #0000BB]$lid[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$t[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$ref[/COLOR][COLOR= #007700];
  }[/COLOR]
[URL="http://www.php.net/arsort"]arsort[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$lid[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<table>
<tr>
<td>Aantal</td>
<td>Gebruikersnaam</td>
</tr>[/COLOR][COLOR= #007700];[/COLOR]
   [URL="http://www.php.net/foreach"]foreach[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$lid[/COLOR] [COLOR= #007700]AS[/COLOR] [COLOR= #0000BB]$aantal[/COLOR] [COLOR= #007700]=>[/COLOR] [COLOR= #0000BB]$ref[/COLOR][COLOR= #007700]) {[/COLOR]
   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<tr>
<td>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$aantal[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</td>
<td>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ref[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]</td>
</tr>[/COLOR][COLOR= #007700];
   }[/COLOR]
   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</table>[/COLOR][COLOR= #007700];[/COLOR]
?>
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren