hulp nodig met een klein php file

Gestart doorDeamonz2 reacties37 weergaven

3 berichten · pagina 1 van 1

Deamonz

Lid · Topicstarter

Berichten
117
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hallo mensen van one2xs,

ik ben bezig met een vote lijst voor mijn minecraft server.
deze lijst laat zien wie er het meest heeft gevote etc.
dit is een stukje van de file dat ik niet fixed krijg.
ik volg een cursus op een site die heel veel geholpen heb maar ik kom niet verder.

[COLOR= #0000BB]<?php
$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"root"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"password"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]

[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"vote"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT minecraft_user, COUNT(id) FROM votes GROUP BY minecraft_user"[/COLOR][COLOR= #007700];[/COLOR] 
     
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

[COLOR= #FF8000]// Print out result[/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]$result[/COLOR][COLOR= #007700])){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Has voted "[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]COUNT(id)[/COLOR][COLOR= #007700]] .[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]minecraft_user[/COLOR][COLOR= #007700]] .[/COLOR][COLOR= #DD0000]" time(s)."[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700];
}[/COLOR]
?>


dit is de code.
dit is het resultaat:
Has voted # %username% time(s)
%username% heb ik ff zo getypet voor de duidelijkheid normaal staat hier een naam.
# is het aantal votes.
$row[COUNT(id)] is het aantal votes oftewel #
en $row[minecraft_user] is de naam van de gebruiker oftewel %username%
Ik wil dit omdraaien maar dat lukt mij niet.
kan iemand helpen?
dit moet er komen te staan
%username% has voted # time(s)
0
Berichten
6.201
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dit zou enigszins moeten werken:

[COLOR= #0000BB]<?php
$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"root"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"password"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]

[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"vote"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT minecraft_user, COUNT(id) FROM votes GROUP BY minecraft_user"[/COLOR][COLOR= #007700];[/COLOR]
    
[COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

[COLOR= #FF8000]// Print out result[/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]$result[/COLOR][COLOR= #007700])){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]minecraft_user[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" has voted "[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]COUNT(id)[/COLOR][COLOR= #007700]] .[/COLOR][COLOR= #DD0000]" time(s)."[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<br />"[/COLOR][COLOR= #007700];
}[/COLOR]
?>
0
Deamonz

Lid · Topicstarter

Berichten
117
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ik heb het aan een vriend gevraagd die wist dat toevallig maar in ieder geval nog bedankt.
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