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
https://forums.phpfreaks.com/topic/115549-solved-forum-nav-bar/#findComment-594050
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.