Justafool schreef:Heb ik gezegd dat het niet hetzelfde is dan? Ik zeg gewoon dat het slecht is om te gebruiken. En dat je liever assoc kan gebruken.Fetch assoc is hetzelfde als arrayEerdere citaten tonen
Shahiem schreef:fetch_array faalt.Eerdere citaten tonen
Justafool schreef:is bijna geen verschil dus wat maakt dat uitEerdere citaten tonen
Shahiem schreef:Waarom mysql_fetch_array, gebruik gewoon fetch_assoc.Dus het maakt wel wat uit. En als je toch een array wilt doen, doe het dan niet op die manier.
Alleen met assoc kun je gegevens alleen aanroepen met $var[naam]
En met array kan je $var[naam] & $var[1]
[PHP] Bij 2 een komma er tussen
fetch_assoc() is bovendien sneller 

Ik gebruik zelf altijd Object heb het script omgebouwd en is dit geworden:
[COLOR= #0000BB]<?php
$onlinesql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= laast_online"[/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= #0000BB]$tellen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$onlinesql[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tellen[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<i>Geen gebruikers online</i>[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$tel[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_object"]mysql_fetch_object[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$onlinesql[/COLOR][COLOR= #007700])) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Online: <i>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$tel[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]$tellen[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]rank[COLOR= #007700]==[/COLOR][COLOR= #DD0000]"lid"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]naam[COLOR= #007700].[/COLOR][COLOR= #DD0000]","[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]rank[COLOR= #007700]==[/COLOR][COLOR= #DD0000]"admin"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=?p=profiel&naam="[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]naam [COLOR= #007700].[/COLOR][COLOR= #DD0000]"><font color="red">"[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]naam [COLOR= #007700].[/COLOR][COLOR= #DD0000]"</font></a>,"[/COLOR][COLOR= #007700];
}}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]rank[COLOR= #007700]==[/COLOR][COLOR= #DD0000]"lid"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]naam[COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];
}[/COLOR] [URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]rank[COLOR= #007700]==[/COLOR][COLOR= #DD0000]"admin"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<a href=?p=profiel&naam="[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]naam [COLOR= #007700].[/COLOR][COLOR= #DD0000]"><font color="red">"[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700]->[/COLOR]naam [COLOR= #007700].[/COLOR][COLOR= #DD0000]"</font></a>"[/COLOR][COLOR= #007700];
}}[/COLOR]
[COLOR= #0000BB]$tel[/COLOR][COLOR= #007700]++;[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</i>[/COLOR][COLOR= #007700];
}}[/COLOR]
?> Wat een omweg zeg 

Hoe zeg jij het dan?
Dat van Sjoerd bijvoorbeeld
Objecten zijn echt slecht om te gebruiken als een fetch. Een object aanmaken kost veel meer tijd en kracht dan bijvoorbeeld assoc, die gewoon een array aanmaakt en vult.
Buiten dat is dat van Sjoerd het netste en het makkelijkste te gebruiken.
Buiten dat is dat van Sjoerd het netste en het makkelijkste te gebruiken.
Ben over gegaan naar Assoc
ik zou het zo doen
$sql = "
SELECT
gebruikersnaam
FROM
members
WHERE
DATE_SUB(NOW(),INTERVAL 20 MINUTE) <= last_online
ORDER BY
last_online ASC
gebruikersnaam ASC
";
if(!$res = mysql_query($sql))
{
trigger_error(mysql_error().<br />In query: .$sql);
}
elseif(mysql_num_rows($res) == 0)
{
// GEEN LEDEN ONLINE
echo Geen resultaten gevonden;
}
else
{
while($row = mysql_fetch_assoc($res))
{
echo $row[gebruikersnaam].<br />;
}
} Ja maar ik wil ook rood als admin is
is vrij simpel toch?
er van uit gaan dat je rank ook in de tabel members staat.
ander een left join gebruiken om een ander tabel te selecteren.
en met een beetje scc kun je dan de rank kleuren dus ook makkelijk als je meerdere rangen hebt en je wilt ze een ander kleurtje geven
[COLOR= #0000BB]<?php
$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"
SELECT
rank,
gebruikersnaam
FROM
members
WHERE
DATE_SUB(NOW(),INTERVAL 20 MINUTE) <= last_online
ORDER BY
last_online ASC
gebruikersnaam ASC
"[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]().[/COLOR][COLOR= #DD0000]<br />In query: [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
[COLOR= #FF8000]// GEEN LEDEN ONLINE[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Geen resultaten gevonden[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[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_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700]))
{[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<span class="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]rank[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">[/COLOR] [COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]</pan><br />[/COLOR][COLOR= #007700];
}
}[/COLOR]
?> er van uit gaan dat je rank ook in de tabel members staat.
ander een left join gebruiken om een ander tabel te selecteren.
en met een beetje scc kun je dan de rank kleuren dus ook makkelijk als je meerdere rangen hebt en je wilt ze een ander kleurtje geven

