Jump to content

[SOLVED] Forum Nav-Bar?


unsider

Recommended Posts

main_cats        sub_cats	     topics
---------       ----------     --------
id	---|	id	---|	id
name	   +---  mid	   +---  sid
	name		name

 

You have your main category being PHP, your sub-category PHP Help and your topic Forum Nav-Bar?

 

<?php
$topic_id = mysql_real_escape_string($_GET['id']); // example

$sql = "SELECT * FROM `topics` WHERE `id`='".$topic_id."'";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);

$sql2 = "SELECT mid,name FROM `sub_cats` WHERE `id`='".$row['sid']."'";
$res2 = mysql_query($sql2) or die(mysql_error());
$row2 = mysql_fetch_assoc($res2);

$sql3 = "SELECT name FROM `main_cats` WHERE `id`='".$row2['mid']."'";
$res3 = mysql_query($sql3) or die(mysql_error());
$row3 = mysql_fetch_assoc($res3);

echo $row3['name'] . " > " . $row2['name'] . " > " . $row['name'];
?>

 

I'm sure you can easily put that into one query, I don't deal with joins :x

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.