Php laatste reactie

Gestart doorWiitse4 reacties24 weergaven

5 berichten · pagina 1 van 1

Wiitse

Lid · Topicstarter

Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb weer php hulp nodig. yummieNu gaat het om in het forum-overzicht te kunnen zien in welk topic de laatste reactie is. Ik heb zelf dit al in elkaar geflanst:

[COLOR= #0000BB]<?php

$fQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM forum_fora ORDER BY rang"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$tQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM forum_topics ORDER BY ldatum DESC"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$tFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tQuery[/COLOR][COLOR= #007700]);[/COLOR]



[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<table>"[/COLOR][COLOR= #007700];[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr>"[/COLOR][COLOR= #007700];[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td></td>"[/COLOR][COLOR= #007700];[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td><b>Catogorie</b></td>"[/COLOR][COLOR= #007700];[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td><b>Topics</b></td>"[/COLOR][COLOR= #007700];[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td><b>Posts</b></td>"[/COLOR][COLOR= #007700];[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td><b>Laatste reactie</b></td>"[/COLOR][COLOR= #007700];[/COLOR]

            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</tr>"[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fQuery[/COLOR][COLOR= #007700])){[/COLOR]

    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR]is_rang[COLOR= #007700]([/COLOR][COLOR= #DD0000]loggedin[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$uRang[/COLOR][COLOR= #007700]) &&[/COLOR] [COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gasten[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){

    }[/COLOR]

    [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<tr>"[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td width=16px>"[/COLOR][COLOR= #007700].[/COLOR]forum_gelezen[COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]uId[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"</td>"[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td width=400px><a href="[/COLOR][COLOR= #007700].[/COLOR]_ROOT_[COLOR= #007700].[/COLOR][COLOR= #DD0000]"catogorie/"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"</a><br />"[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<i>"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]beschrijving[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"</i></td>"[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td width=60px>"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]topics[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000].[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]"</td>"[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td width=75px>"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/number_format"]number_format[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]posts[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000],[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000].[/COLOR][COLOR= #007700]).[/COLOR][COLOR= #DD0000]"</td>"[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<td width=120px>In <a href="[/COLOR][COLOR= #007700].[/COLOR]_ROOT_[COLOR= #007700].[/COLOR][COLOR= #DD0000]"topic/"[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$tFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">"[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$tFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]onderwerp[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"</a></td>"[/COLOR][COLOR= #007700];[/COLOR]

        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</tr>"[/COLOR][COLOR= #007700];[/COLOR]

        [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++;

    }

}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"</table>"[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]

    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Er zijn nog geen fora die u mag zien"[/COLOR][COLOR= #007700];

}[/COLOR]

?>


Dit werkt wel alleen word nu achter elk forum de allerlaatste topic waarin gereageerd is gezet. Niet alleen die van dat forum! Ik wil dat dat per forum gedaan word.

En als ik hier toch mee bezig ben is er nog iets wat ik hierbij graag wil. Dat is dat, als de titel "Ik zoek een leven" is dat er dan niet die lange titel staat maar "Ik... ...leven" of "Ik zoek... ...leven" of zoiets. yummie
Als iemand me wil helpen ben ik super blij! biggrin
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je zou voor het allerlaats geposte forum bericht DESC LIMIT 1 kunnen doen.
en voor vraag 2:

iets van dit:

if(strlen($row->veldnaam) > 5){
echo substr($row->veldnaam, 0, 5)...;
}
else{
echo $row->veldnaam;
}

bij strlen checkt hij hoe lang de variable is, in dit geval als hij grote dan 5 is dan bewerkt hij heb en kort hem in tot 5 characters en vervolgens zet hij er 2 punten achter.
als ik dit natuurlijk allemaal kloppend zegwink
0
Wiitse

Lid · Topicstarter

Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zou je mijn script kunnen aanpassen? Ik snap nummer 2 niet echt. bloosEn trouwens, punt 1 bedoel ik anders, hij nam zo al alleen de laatste doordat ik daar DESC had staan. yummie Ik bedoel dat daar niet de laatste topic waarin gereageerd is komt, maar het laatste topic in dat forum waarin gereageerd is. Snappie?
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
stap 2 kan ik niet echt doen, want ik weet niet welke variable wat is, dus wordt nogal latsig maar ik denk dat je $fFetch[posts] moet vervangen voor wat ik zei en dan de variable aanpassen

voor stap 1 moet je, voor zover ik jouw begrijp, een DESC zetten op forum id x. dus je hebt voor offtopic bijvoorbeeld id 5 en dan moet je een qeury maken wat er ongeveer als volgs uit ziet:

mysql_query("SELECT * FROM topics WHERE forumid = $_GET[id] DESC LIMIT 1");

iets in die richting.
succes
0
Wiitse

Lid · Topicstarter

Berichten
6.722
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt. Ik ga morgen het proberen, ik heb nu geen tijd dus je hoort morgen wel als het me is gelukt. wink
EDIT:// De query die ik nu heb is dit:

mysql_query("SELECT * FROM forum_topics WHERE forum = $fQuery[id] ORDER BY ldatum DESC LIMIT 1");


Alleen hij geeft nu deze melding:

Quote:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/max/domains/scriptmania.nl/public_html/beta/forum.php on line 14

Die query staat natuurlijk op regel 14. yummieKan iemand me helpen? Ik zie niet wat de fout is. confused
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