Im trying to get it to remove the text text (marked below) from the sub-categories section, but keep it for the parent section. Text i want to show only for parent, not sub-categories: echo'You are currently viewing: <b>'.$_GET[id].'</b> tutorials<br>'; echo'<hr noshade size="1">'; echo'<br><table class="sub" border="0" width="100%" valign="center">'; echo'<tr><td colspan="2" class="menu" align="center"><b>Sub-Categories</b></td></tr>'; echo''.$scat.''; echo'</table><br>'; PHP: The code i have: $fsql=mysql_query(" SELECT * FROM categories WHERE title = '$_GET[id]' "); while ($row = mysql_fetch_array($fsql)) { $id = $row["id"]; $fcsql=mysql_query("SELECT * FROM categories WHERE parent='$id'"); while ($row = mysql_fetch_array($fcsql)) { $cid = $row["id"]; $ctitle = $row["title"]; $cparent = $row["parent"]; $i2++; $result = (1 & $i2) ? 'Odd' : 'Even'; if($result == 'Odd'){ $scat.='<tr><td class="menu" width="50%" valign="center"><img src="images/folder.gif"> <a href="tutorials.php?id='.$ctitle.'">'.$ctitle.'</a></td>'; }else{ $scat.='<td class="menu" width="50%" valign="center"><img src="images/folder.gif"> <a href="tutorials.php?id='.$ctitle.'">'.$ctitle.'</a></td></tr>'; } } } echo'You are currently viewing: <b>'.$_GET[id].'</b> tutorials<br>'; echo'<hr noshade size="1">'; echo'<br><table class="sub" border="0" width="100%" valign="center">'; echo'<tr><td colspan="2" class="menu" align="center"><b>Sub-Categories</b></td></tr>'; echo''.$scat.''; echo'</table><br>'; PHP:
How does the code know when it's displaying the parent and when it's displaying the sub-section? Is it something to do with $_GET[id]? If it is, then perhaps you can use the isset() function? Forgive me if I'm just being thick... Cryo.
Yes, $_GET[id] gets the title of the category and then it checks if that title is a parent or sub-category. Ok i got it, i guess i just had to take a break for awhile I used: $gn=mysql_query("SELECT parent FROM categories WHERE title= '$_GET[id]'"); $subs = mysql_fetch_array($gn); if($subs[parent]==0){ echo'You are currently viewing: <b>'.$_GET[id].'</b> tutorials<br>'; echo'<hr noshade size="1">'; echo'<br><table class="sub" border="0" width="100%" valign="center">'; echo'<tr><td colspan="2" class="menu" align="center"><b>Sub-Categories</b></td></tr>'; echo''.$scat.''; echo'</table><br>'; } PHP: