unsider Posted July 19, 2008 Share Posted July 19, 2008 PHP Freaks Forums > PHP > PHP Help > Start new topic Can someone explain the logic behind this method? What it's called? Point me towards a tutorial? Thanks. Link to comment https://forums.phpfreaks.com/topic/115549-solved-forum-nav-bar/ Share on other sites More sharing options...
marcus Posted July 19, 2008 Share Posted July 19, 2008 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 More sharing options...
unsider Posted July 19, 2008 Author Share Posted July 19, 2008 Thanks, makes perfect sense, confirms a few ideas I had, and completes my thought. And the single query won't be a problem. Link to comment https://forums.phpfreaks.com/topic/115549-solved-forum-nav-bar/#findComment-594052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.