Kleine Vragen Topic #4
Mcpoesen schreef:Wat krijg je als je € gebruikt?Als ik bij whmcs € intyp dan krijg ik een zwarte vierkant met een ?
Hoe los ik dat op?
Mcpoesen schreef:Wat gebeurt er dan wel? Wat zie je dan?Dat werkt niet
Je karaktercodering klopt niet.
Zorg dat je overal (HTML, PHP, verbinding met MySQL en MySQL zelf) dezelfde codering gebruikt: bij voorkeur utf8mb4.
Zorg dat je overal (HTML, PHP, verbinding met MySQL en MySQL zelf) dezelfde codering gebruikt: bij voorkeur utf8mb4.Waarom wordt mijn code opeens heel traag met die if($cardCount < $aantalCards) erbij?
toevoeging op vr 21 oktober 2016, 15:20:40:
Wanneer ik regel 23 en 43 uit comment werkt het wel
[COLOR= #0000BB]<?php
$aantalkolommen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aantalads[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]7[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aantalCards[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$adcount[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$cardCount[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$groups[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$group[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/array_push"]array_push[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$group[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]GroupID[/COLOR][COLOR= #007700]]);
}[/COLOR]
[URL="http://www.php.net/shuffle"]shuffle[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$groupCount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][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]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$groupCount[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$cardCount[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$aantalCards[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<div class="row cells$aantalkolommen">"[/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #0000BB]$cardDice[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$cardDice[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]static/adcard.php[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$group[/COLOR] [COLOR= #007700]= new[/COLOR] Group[COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]static/groupcard.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;
}[/COLOR]
[COLOR= #0000BB]$count[/COLOR][COLOR= #007700]++;[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$aantalkolommen[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</div>"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #0000BB]$cardCount[/COLOR][COLOR= #007700]++;
}
}[/COLOR]
?> toevoeging op vr 21 oktober 2016, 15:20:40:
Wanneer ik regel 23 en 43 uit comment werkt het wel

Stef schreef:toevoeging op vr 21 oktober 2016, 15:20:40:Waarom wordt mijn code opeens heel traag met die if($cardCount < $aantalCards) erbij?[COLOR= #0000BB]<?php $aantalkolommen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]7[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$aantalCards[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$adcount[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$cardCount[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$groups[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR] [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$group[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/array_push"]array_push[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$group[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]GroupID[/COLOR][COLOR= #007700]]); }[/COLOR] [URL="http://www.php.net/shuffle"]shuffle[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$groupCount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][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]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$groupCount[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$cardCount[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$aantalCards[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<div class="row cells$aantalkolommen">"[/COLOR][COLOR= #007700]; }[/COLOR] [COLOR= #0000BB]$cardDice[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR][COLOR= #007700]);[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$cardDice[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]static/adcard.php[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [COLOR= #0000BB]$group[/COLOR] [COLOR= #007700]= new[/COLOR] Group[COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]]);[/COLOR] [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]static/groupcard.php[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++; }[/COLOR] [COLOR= #0000BB]$count[/COLOR][COLOR= #007700]++;[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$aantalkolommen[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</div>"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]; }[/COLOR] [COLOR= #0000BB]$cardCount[/COLOR][COLOR= #007700]++; } }[/COLOR] ?>
Wanneer ik regel 23 en 43 uit comment werkt het wel

Het klinkt alsof hij gewoon nooit door:
if($cardCount < $aantalCards) { komt. daardoor wordt de increment ook niet hoger en blijft hij loopen.
Dan krijg je eigenlijk een infinite loop.
Stef schreef:toevoeging op vr 21 oktober 2016, 15:20:40:Waarom wordt mijn code opeens heel traag met die if($cardCount < $aantalCards) erbij?[COLOR= #0000BB]<?php $aantalkolommen[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]7[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$aantalCards[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$adcount[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$cardCount[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$groups[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR] [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$result[/COLOR] [COLOR= #007700]as[/COLOR] [COLOR= #0000BB]$group[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/array_push"]array_push[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$group[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]GroupID[/COLOR][COLOR= #007700]]); }[/COLOR] [URL="http://www.php.net/shuffle"]shuffle[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$groupCount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][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]$i[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$groupCount[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$cardCount[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]$aantalCards[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<div class="row cells$aantalkolommen">"[/COLOR][COLOR= #007700]; }[/COLOR] [COLOR= #0000BB]$cardDice[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR][COLOR= #007700]);[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$cardDice[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$aantalads[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]static/adcard.php[/COLOR][COLOR= #007700]; }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR] [COLOR= #0000BB]$group[/COLOR] [COLOR= #007700]= new[/COLOR] Group[COLOR= #007700]([/COLOR][COLOR= #0000BB]$groups[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]]);[/COLOR] [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]static/groupcard.php[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++; }[/COLOR] [COLOR= #0000BB]$count[/COLOR][COLOR= #007700]++;[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$aantalkolommen[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</div>"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$count[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]; }[/COLOR] [COLOR= #0000BB]$cardCount[/COLOR][COLOR= #007700]++; } }[/COLOR] ?>
Wanneer ik regel 23 en 43 uit comment werkt het wel

Je kan beter een for loop gebruiken, die telt totdat $i gelijk is aan `$aantalCards`. Zo voorkom je infinity loops op deze manier.
Waarmee zou ik een systeem kunnen maken dat wanneer er een nieuw bericht is dat die er gelijk bij komt? zoals op dit forum of in een chat? (welke code) ik had het laatst een keer gehoord.. 

Jesper schreef:WebsocketsWaarmee zou ik een systeem kunnen maken dat wanneer er een nieuw bericht is dat die er gelijk bij komt? zoals op dit forum of in een chat? (welke code) ik had het laatst een keer gehoord..
Jesper schreef:Op dit forum gebeurt het met AJAX geloof ikWaarmee zou ik een systeem kunnen maken dat wanneer er een nieuw bericht is dat die er gelijk bij komt? zoals op dit forum of in een chat? (welke code) ik had het laatst een keer gehoord..

Jesper schreef:Zoals reeds aangegeven voor Dylan is websockets een goed protocol hiervoor. Het mooie is dat je hiermee vanaf de server naar de client kan pushen, maar je hier echter wel een eigen server voor nodig zult hebben. Als je host op een shared hosting kan je dus beter kiezen voor Ajax, hier kun je helaas niet pushen naar de client, dus zul je dan moeten checken op nieuwe posts.Waarmee zou ik een systeem kunnen maken dat wanneer er een nieuw bericht is dat die er gelijk bij komt? zoals op dit forum of in een chat? (welke code) ik had het laatst een keer gehoord..
Correct me if Im wrong haha.
Dylan schreef:DankjeWebsocketsEerdere citaten tonen
Jesper schreef:Waarmee zou ik een systeem kunnen maken dat wanneer er een nieuw bericht is dat die er gelijk bij komt? zoals op dit forum of in een chat? (welke code) ik had het laatst een keer gehoord..
Maar als ik nou meedere chats wil? Hoe wil ik dat doen op 1 server?