tags:

views:

48

answers:

1

Hello new to PHP and in a bit of a bind. I need to diplay a nav bar PID = "nid" nid is the page i am on so say i am on a page A and page A has 5 sub nav categories(child ID) then they will display on the left side. MY problem here is that the cid and its name are on two different tables..(tables are listed at bottom) Thanks

$navQuery = 'SELECT * FROM tblnavpc WHERE PID = \''.$nid.'\''; $navQueryResults = mysql_query($navQuery) or die(mysql_error());


$numNavItems = mysql_num_rows($navQueryResults);    echo'<tr>
<td>align="left" valign="top" class="medium"><h1>'. $NavName .'</h1></td>
  /tr>';
// echo '<br>Nav Items'.  .'<br>';

for($i = 0; $i < $numNavItems; $i++){
    $childName = mysql_result($getResults1,$i,"NavName");
    $childNavID = mysql_result($navQueryResults,$i,"cID");
    echo '

align="left" valign="top" class="medium">
href="cat_ap~pnid~'.$nid.'~nid~'.$childnavID.'~post.htm">'.$childName.'

    </tr>';


}

table: tblNavPC
pcid (parent child id)
pid (parent id)
cid (child id)
related navpcdate

Table: tblNav
NavID
NavName
NavDisplayName

A: 

Sounds like you're just looking for a join. Your query should be something like this:

SELECT n.NavDisplayName
FROM tblNavPC AS pc
    LEFT JOIN tblNav AS n ON n.NavID = pc.cid
WHERE pc.pid = $nid;

(change the SELECT clause as needed to get the information you need)

Chad Birch