Moeite met whiles

Gestart doorMarvinn9 reacties47 weergaven

10 berichten · pagina 1 van 1

Marvinn

Lid · Topicstarter

Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sjoerd gaf antwoord op me vraag:
Sjoerd schreef:
Eerdere citaten tonen
Nickjexx schreef:
Ik heb een script die weergeeft de nieuwste 5 leden, maar nu wil ik dus een button en als je er op klikt krijg je nog 5 resultaten (in totaal 10 dus)
Haal er in je query gewoon 10 op (ORDER BY id DESC o.i.d.)
Voor de [func]while[/func] zet je dan iets als $i = 0;
In de while kun je dan doen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++ ==[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="verborgen" style="display: none;">[/COLOR][COLOR= #007700]; }[/COLOR]


Na de while kun je zetten:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</div><input type="submit" onclick="document.getElementById(verborgen).style.display = lock"/>[/COLOR][COLOR= #007700];[/COLOR]


En dan heb je het zon beetje.
Maar kan iemand me helpen? Want ik heb veel geprobeerd. Maar het lukt me niet?

Kan iemand het inbouwen in dit:

[COLOR= #0000BB]<?php
$sql_top_5_members[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam,member_id, DATE_FORMAT(regdatum, %d-%m-20%y) AS regdatum FROM leden ORDER BY member_id DESC LIMIT 5"[/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]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
?>
<table width=200px border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" style="border-bottom:1px solid #00AACD"><strong>Laatste 5 leden:</strong></td>
    </tr>
    <tr>
        <td style="padding-left:14px; padding-top:4px;"><em>Gebruiker</em></td>
        <td width="75px" style="padding-top:4px;" align="right"><em>Lid sinds</em></td>
    </tr>
[COLOR= #0000BB]<?php[/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]$sql_top_5_members[/COLOR][COLOR= #007700])) {[/COLOR] ?>
    <tr>
        <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700];[/COLOR] ?>. <a href=?p=profiel&mid=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]member_id[/COLOR][COLOR= #007700]];[/COLOR] ?>>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]999[/COLOR][COLOR= #007700]));[/COLOR] ?></a></td>
        <td align="right">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]regdatum[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
    </tr>
[COLOR= #0000BB]<?php $i[/COLOR][COLOR= #007700]++; 
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700];[/COLOR]
?>


Want ik snap er echt niks van. En nu voel ik me zielig cry
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$sql_top_5_members[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam,member_id, DATE_FORMAT(regdatum, %d-%m-20%y) AS regdatum FROM leden ORDER BY member_id DESC LIMIT 10"[/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]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
?>
<table width=200px border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" style="border-bottom:1px solid #00AACD"><strong>Laatste 5 leden:</strong></td>
    </tr>
    <tr>
        <td style="padding-left:14px; padding-top:4px;"><em>Gebruiker</em></td>
        <td width="75px" style="padding-top:4px;" align="right"><em>Lid sinds</em></td>
    </tr>
[COLOR= #0000BB]<?php[/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]$sql_top_5_members[/COLOR][COLOR= #007700])) {[/COLOR] ?>
    <tr[COLOR= #0000BB]<?[/COLOR]php [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++ >[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] class="verborgen" style="display: none;"[/COLOR][COLOR= #007700]; }[/COLOR] ?>>
        <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700];[/COLOR] ?>. <a href=?p=profiel&mid=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]member_id[/COLOR][COLOR= #007700]];[/COLOR] ?>>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]999[/COLOR][COLOR= #007700]));[/COLOR] ?></a></td>
        <td align="right">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]regdatum[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
    </tr>
[COLOR= #0000BB]<?php $i[/COLOR][COLOR= #007700]++;
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</table><input type="submit" onclick="document.getElementByClass(verborgen).style.display = block" value="Meer?"/>[/COLOR][COLOR= #007700];[/COLOR]
?>

wink
0
Marvinn

Lid · Topicstarter

Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Werkt niet?

Laatste 5 leden:
Gebruiker    Lid sinds
2. djwoenwanXXL    04-08-2012
4. youknowme    04-08-2012
6. niekherpinia1    03-08-2012


toevoeging op 4 augustus 2012, 12:08:22:
Dat is trouwens ook wat ik steeds kreeg toen ik het zelf probeerde cry
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$sql_top_5_members[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam,member_id, DATE_FORMAT(regdatum, %d-%m-20%y) AS regdatum FROM leden ORDER BY member_id DESC LIMIT 10"[/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]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
?>
<table width=200px border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" style="border-bottom:1px solid #00AACD"><strong>Laatste 5 leden:</strong></td>
    </tr>
    <tr>
        <td style="padding-left:14px; padding-top:4px;"><em>Gebruiker</em></td>
        <td width="75px" style="padding-top:4px;" align="right"><em>Lid sinds</em></td>
    </tr>
[COLOR= #0000BB]<?php[/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]$sql_top_5_members[/COLOR][COLOR= #007700])) {[/COLOR] ?>
    <tr[COLOR= #0000BB]<?[/COLOR]php [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] class="verborgen" style="display: none;"[/COLOR][COLOR= #007700]; }[/COLOR] ?>>
        <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700];[/COLOR] ?>. <a href=?p=profiel&mid=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]member_id[/COLOR][COLOR= #007700]];[/COLOR] ?>>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]999[/COLOR][COLOR= #007700]));[/COLOR] ?></a></td>
        <td align="right">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]regdatum[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
    </tr>
[COLOR= #0000BB]<?php $i[/COLOR][COLOR= #007700]++;
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</table><input type="submit" onclick="document.getElementByClass(verborgen).style.display = block" value="Meer?"/>[/COLOR][COLOR= #007700];[/COLOR]
?>
0
Berichten
5.897
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo

[COLOR= #0000BB]<?php
$sql_top_5_members[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam,member_id, DATE_FORMAT(regdatum, %d-%m-20%y) AS regdatum FROM leden ORDER BY member_id DESC LIMIT 10"[/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]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
?>
<table width=200px border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" style="border-bottom:1px solid #00AACD"><strong>Laatste 5 leden:</strong></td>
    </tr>
    <tr>
        <td style="padding-left:14px; padding-top:4px;"><em>Gebruiker</em></td>
        <td width="75px" style="padding-top:4px;" align="right"><em>Lid sinds</em></td>
    </tr>
[COLOR= #0000BB]<?php[/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]$sql_top_5_members[/COLOR][COLOR= #007700])) {[/COLOR] ?>
    <tr[COLOR= #0000BB]<?[/COLOR]php [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] class="verborgen" style="display: none;"[/COLOR][COLOR= #007700]; }[/COLOR] ?>>
        <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700];[/COLOR] ?>. <a href=?p=profiel&mid=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]member_id[/COLOR][COLOR= #007700]];[/COLOR] ?>>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]999[/COLOR][COLOR= #007700]));[/COLOR] ?></a></td>
        <td align="right">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]regdatum[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
    </tr>
[COLOR= #0000BB]<?php $i[/COLOR][COLOR= #007700]++;
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</table><input type="submit" onclick="document.getElementByClass(verborgen).style.display = block" value="Meer?"/>[/COLOR][COLOR= #007700];[/COLOR]
?>


toevoeging op 4 augustus 2012, 121059:
Stomme Ajax sadley
0
Marvinn

Lid · Topicstarter

Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nu klopt het qua nummering, alleen de knop "Meer?" doet niks yummie
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heb je t ergens live staan?
0
Marvinn

Lid · Topicstarter

Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja hoor.
http://www.habbotjes.be beetje onderaan bij Statistieken.
0
Berichten
3.283
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$sql_top_5_members[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT gebruikersnaam,member_id, DATE_FORMAT(regdatum, %d-%m-20%y) AS regdatum FROM leden ORDER BY member_id DESC LIMIT 10"[/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]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR]
?>
<table width=200px border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2" style="border-bottom:1px solid #00AACD"><strong>Laatste 5 leden:</strong></td>
    </tr>
    <tr>
        <td style="padding-left:14px; padding-top:4px;"><em>Gebruiker</em></td>
        <td width="75px" style="padding-top:4px;" align="right"><em>Lid sinds</em></td>
    </tr>
[COLOR= #0000BB]<?php[/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]$sql_top_5_members[/COLOR][COLOR= #007700])) {[/COLOR] ?>
    <tr[COLOR= #0000BB]<?[/COLOR]php [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]) {[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000] class="verborgen" style="display: none;"[/COLOR][COLOR= #007700]; }[/COLOR] ?>>
        <td>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700];[/COLOR] ?>. <a href=?p=profiel&mid=[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]member_id[/COLOR][COLOR= #007700]];[/COLOR] ?>>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/stripslashes"]stripslashes[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruikersnaam[/COLOR][COLOR= #007700]],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]999[/COLOR][COLOR= #007700]));[/COLOR] ?></a></td>
        <td align="right">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]regdatum[/COLOR][COLOR= #007700]];[/COLOR] ?></td>
    </tr>
[COLOR= #0000BB]<?php $i[/COLOR][COLOR= #007700]++;
}[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</table><input type="submit" onclick="$(.verborgen).css(display, table-row);$(this).css(display, none);" value="Meer?"/>[/COLOR][COLOR= #007700];[/COLOR]
?>


Ik dacht dat getElementByClass() bestond, maar dat blijkt dus niet zo te zijn, maar ik zie dat je jQuery gebruikt, dus dan kunnen we het zo oplossen....

edit: nog een aanpassing om de knop te laten verdwijnen nadat er op geklikt is wink
0
Marvinn

Lid · Topicstarter

Berichten
2.609
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja super, tnx pompom
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