bonjour, voila j'ai deux select pour choisir la catégorie principal et la sous catégorie, tout es stoké dans la base mais sur deux tables différentes,

ce que j'ai actuellement :
catégorie1
catégorie2
catégorie2

et ensuite

catégorie1/souscatégorie
catégorie1/souscatégorie
catégorie1/souscatégorie
--
catégorie2/souscatégorie
catégorie2/souscatégorie
catégorie2/souscatégorie
--
catégorie3/souscatégorie
catégorie3/souscatégorie
catégorie3/souscatégorie
ce que je souhaite faire c'est :

catégorie1/souscatégorie1/souscatégorie2/souscatégorie3/

catégorie2/souscatégorie1/souscatégorie2/souscatégorie3/

catégorie3/souscatégorie1/souscatégorie2/souscatégorie3/
mes codes actuels :

catégories :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
    // Get category names
    $sql = "SELECT catid, catname AS catname
            FROM $t_cats
            WHERE enabled = '1'
            $sortcatsql";       //
    $res = mysql_query($sql);
 
    while ($row = mysql_fetch_array($res))
    {
 
     $idcat ="/?view=post&cityid=".$xcityid."&lang=fr&lang=fr&catid=".$row['catid']."&subcatid=";
      echo '<option value="'.$idcat.'"';
      echo '>'.$row['catname'].'</option>';     
 ?>
sous catégories :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
    // Get subcategory names
    $sql = "SELECT subcatid, subcatname AS subcatname
            FROM $t_subcats WHERE catid = $_GET[catid] order by subcatname";
    $res = mysql_query($sql);
 
    while ($row = mysql_fetch_array($res))
    {
      $idsub= "/?view=post&cityid=".$xcityid."&lang=".$xlang."&catid=". $_GET['catid']."&subcatid=".$row['subcatid']."";
      $idsubcat ="/?view=post&cityid=".$xcityid."&lang=fr&catid=".$row['catid']."&subcatid=".$row['catid']."";
      echo '<option value="'.$idsub.'"';
      echo '>'.$row['subcatname'].'</option>';  
 ?>
ce que j'ai fais mais je doit me planter

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
<?php
	// Get category names
	$sql = "SELECT a.catid, a.catname ,b.subcatid, b.subcatname
			FROM $t_subcats b
			INNER JOIN $t_cats a ON a.catid = b.catid
			WHERE enabled = '1'
			$sortcatsql";
 
 
	$res = mysql_query($sql);
 
	while ($row = mysql_fetch_array($res))
 
	{
 
 
     $idcat ="/?view=post&cityid=".$xcityid."&lang=fr&lang=fr&catid=".$row['catid']."&subcatid=";
      echo '<option value="'.$idcat.'"';
      echo '>'.$row['catname'].'</option>';
      echo '<option>'.$row['subcatname'].'</option>';	  
 ?>
merci


EDIT

j'ai donc trouvé la jointure, reste le select a mettre en place car la j'ai le titre de la catégorie a chaque sous catégorie :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
	// Get category names
	$sql = "SELECT a.catid, a.catname , b.subcatid, b.subcatname, b.catid 
			FROM $t_cats a
			INNER JOIN $t_subcats b ON a.pos = b.catid 
			";
 
 
	$res = mysql_query($sql);
 
	while ($row = mysql_fetch_array($res))
 
	{
 
 
     $idcat ="?view=post&cityid=".$xcityid."&lang=fr&lang=fr&catid=".$row['catid']."&subcatid=";
      echo '<option value="'.$idcat.'"';
      echo '>'.$row['catname'].'</option>';
      echo '<option>'.$row['subcatname'].'</option>';	  
 ?>