Toon posts:

[PHP] MySQL query's combineren

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb dus een stukje code geschreven. Maar ik wil de query in de while graag combineren met de query boven de while. Het wil mij maar niet lukken en ik weet überhaupt niet of het wel mogelijk is.

Kan iemand me helpen? |:(
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?

require_once("../include/include.inc.php");
$inhoud = $core->pad.'include/tpl/forum.tpl';
require_once($core->pad."include/header.inc.php");

$s_cats = mysql_query("Select cat.id, cat.titel As cat_titel From forum_cats As cat Order By volgorde") or die(mysql_error());
$core->sql_count++;
while($f_cats = mysql_fetch_object($s_cats)) {
    $s_forums = mysql_query("Select f.titel, f.id, f.beschrijving, f.reacties, f.topics From forum_forums As f Where f.cat = '".$f_cats->id."' Group By f.id Order By volgorde") or die(mysql_error());
    $core->sql_count++;
    
    // categorie
    $tpl->newBlock("tabel");
    $tpl->newBlock("categorie_lijst");
    $tpl->assign("tabel.titel", $f_cats->cat_titel);
    
    if(!mysql_num_rows($s_forums)) {
        // geen forums
        echo "NIKS!";
    }
    else {
        // wel forums
        while($f_forums = mysql_fetch_object($s_forums)) {
            $tpl->newBlock("forum_lijst");
            $tpl->assign(array("forum_titel"    => $f_forums->titel        ,
                               "topics"         => $f_forums->aantal_topics,
                               "reacties"       => $f_forums->aantal_reacties     ,
                ));
        }
    }
}

require_once($core->pad."include/output.inc.php");

?>

  • eek
  • Registratie: Februari 2001
  • Laatst online: 06-04-2020

eek

@MagickNET

Skill is when luck becomes a habit.


Verwijderd

Topicstarter
Ik heb dus de manual van MySQL al gedownload.

Daar wordt ik niet zoveel wijzer van. :(

  • djc
  • Registratie: December 2001
  • Laatst online: 08-09-2025

djc

SELECT cat.id, cat.titel AS cat_titel, f.titel, f.id, f.beschrijving, f.reacties, f.topics
FROM forum_cats AS cat, forum_forums AS f
WHERE f.cat=cat.id
ORDER BY volgorde

Leer SQL, kijk onder JOINs.

Rustacean


  • Sybr_E-N
  • Registratie: December 2001
  • Nu online
Verwijderd schreef op 01 oktober 2002 @ 22:02:
Ik heb dus de manual van MySQL al gedownload.

Daar wordt ik niet zoveel wijzer van. :(
Er zijn genoeg tut's in omloop op internet, btw.

Verwijderd

Topicstarter
Ja, ik snap het ook wel redelijk..

Als ik hem zo zie had ik het zelf ook wel moeten kunnen :-P
Pagina: 1