Ophalen van bepaalde categorie

Gestart doorNicopara8 reacties40 weergaven

9 berichten · pagina 1 van 1

Nicopara

Lid · Topicstarter

Berichten
3.052
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo

Ik heb een forumsysteem.
Ik moet één bepaalde categorie eruithalen om te tonen op de nieuwspagina.
de categorie is 1.
Ik heb dit, maar het werkt natuurlijk niet:

[COLOR= #0000BB]<?
    $sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT id,titel,cat FROM topics where cat =1 ORDER BY id DESC"[/COLOR][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/echo"]echo[/URL][COLOR= #DD0000]"<p> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]" &raquo; </p>"[/COLOR][COLOR= #007700];[/COLOR]
?>


Wat moet eraan veranderen?
Hier haalt hij de titels mee op. (zou moeten)
En als ze er op klikken moet het artikel tevoorschijn komen.

Hoe doe je dat?

Graag nuttige reacties graag emo
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
res ipv row ? emo
0
Berichten
94
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nee Shahiem, daar ligt het niet aan.

Waarschijnlijk heb je nog geen database connectie en moet je nog wel even naar je config bestand linken. Dan word het iets als dit:

[COLOR= #0000BB]<?[/COLOR]
    [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"config/config.php"[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT id,titel,cat FROM topics where cat =1 ORDER BY id DESC"[/COLOR][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/echo"]echo[/URL][COLOR= #DD0000]"<p> "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]" &raquo; </p>"[/COLOR][COLOR= #007700];[/COLOR]
?>


Het zou zo moeten werken denk ik.
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
FAAAL

[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT titel FROM topics WHERE cat = 1 ORDER BY id DESC"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p>[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] &raquo;</p>[/COLOR][COLOR= #007700];

}[/COLOR]
?>
0
Nicopara

Lid · Topicstarter

Berichten
3.052
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@ Jeroen.

Connectie staat bovenaan emo
Dat van Erik werkt. Tnx smile
En hoe doe ik dat hij met een link naar dat artikel verwijst? Dus link met ID. bloos
Daar kom het artikel dan tevoorschijn. (naam in database hiervoor is "bericht")
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, titel FROM topics WHERE cat = 1 ORDER BY id DESC"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p><a href="http://siteurl.extensie/forum?topic=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] ">[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000] &raquo;</a></p>[/COLOR][COLOR= #007700];

}[/COLOR]
?>
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT id, titel FROM topics WHERE cat = 1 ORDER BY id DESC"[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
{[/COLOR]
    
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p><a href="/forum?topic=[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">[/COLOR][COLOR= #007700].[/COLOR]htmlentities[COLOR= #007700]([/COLOR][COLOR= #0000BB]$fetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]titel[/COLOR][COLOR= #007700]],[/COLOR] ENT_QUOTES[COLOR= #007700]).[/COLOR][COLOR= #DD0000]</a> &raquo;</p>[/COLOR][COLOR= #007700];

}[/COLOR]
?>
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
PS: Erik, je hebt de id nog niet opgehaald yummie
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jawel biggrin
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