Meerde gebruikers ophalen

Gestart doorDylan4 reacties32 weergaven

5 berichten · pagina 1 van 1

Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ik heb dit:

[COLOR= #0000BB]<?php
                                    $get[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE gekocht = 1"[/COLOR][COLOR= #007700]);[/COLOR]
                                    [COLOR= #0000BB]$get2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]);[/COLOR]
                                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$get2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
                                    ?>


ik wil dus alle namen weer geven die iets hebben gekocht. alleen hij haalt er maar 1 op terwijl en meerder zijn?
0
Berichten
4.451
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$get[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE gekocht = 1"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$get2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];
}[/COLOR]
?>


zo dus
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Thanks, hoe zorg je er voor dat er overal een komma komt en bij de laaste naam niet?

Dus:

Piet, Jan, Kees, Robb
0
Berichten
473
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$get[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE gekocht = 1"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]))
{[/COLOR]
  [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$get2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]$count[/COLOR][COLOR= #007700]) 
  {[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000], [/COLOR][COLOR= #007700];
  }[/COLOR]
  [COLOR= #0000BB]$count[/COLOR][COLOR= #007700]++;
}[/COLOR]
?>


Zo volgens mij wink
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Habbooo schreef:
[COLOR= #0000BB]<?php
$get[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE gekocht = 1"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]))
{[/COLOR]
  [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$get2[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
  [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$get[/COLOR][COLOR= #007700]) !=[/COLOR] [COLOR= #0000BB]$count[/COLOR][COLOR= #007700]) 
  {[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000], [/COLOR][COLOR= #007700];
  }[/COLOR]
  [COLOR= #0000BB]$count[/COLOR][COLOR= #007700]++;
}[/COLOR]
?>
Zo volgens mij wink
Is juist wink
Trouwens, geef duidelijke namen aan je querys, dat maakt je script overzichtelijker wink
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