I have some code that creates a very nice indented list like this:
  • first item
  • second item
    • Child of Second Item
  • third item


Table A has a column for id, childID and name. The code works just fine for a single table but if I want to add another table and remove the duplicates using WHEN tableB.tableAChildID = tableA.childID I get no results. Here's the code that is not working:
PHP Code:
<?php
    $parentid 
0// assuming that 0 is the main category.
    
get_sub_cats($parentid);
    function 
get_sub_cats($parentid) {
    
    
$sql "SELECT
    tableA.id, tableA.childID, tableA.name,
    tableB.tableAchildID
    FROM tableA, tableB
    WHERE tableA.childID = "
.$parentid."
        AND tableA.childID = tableB.tableAChildID
    "

    
$countID $rec['tableA.id'];
    
$run mysql_query($sql);
    
$newLink "'bizCatEdit.php?recordID=" ;
    
$hypnen "'";
    echo 
'<ul class="aqtree3clickable">';
        while (
$rec mysql_fetch_assoc($run)) {
        echo 
'<li />SN:'$rec['id'], ' - ',  $rec['bcName'], ' / '$rec['BBS']; 
        
get_sub_cats($countID);
        }
    echo 
'</ul>';
    }
    
?>
If I remove the AND method I end up with a table that looks like this:
  • first item
  • first item
  • first item
  • second item
  • second item
  • second item
  • Child of Second Item
  • Child of Second Item
  • Child of Second Item
  • third item
  • third item
  • third item

Removing
PHP Code:
 $countID $rec['tableA.id']; 
and changing the line
PHP Code:
 get_sub_cats($countID); 
to
PHP Code:
 get_sub_cats($rec['id']); 
Brings back the indents like this:
  • first item
  • first item
  • first item
  • second item
    • Child of Second Item
  • second item
    • Child of Second Item
  • second item
    • Child of Second Item
  • third item
  • third item
  • third item

Any ideas how I can remove the duplicates?