Tripic Posted January 28, 2007 Share Posted January 28, 2007 Ok so heres the problem and im still fairley new to php.Im trying to build a completley dynamic menu system for my website using two tables thae parent table being Modules and the child table being menu basically what i want to do is for evry module that is set to be a menu and on the side of the page i tell it to it creates a table as follows[table][tr][td]Module Name[/td][/tr][tr][td]$menu here[/td][/tr][tr][td][/td][/tr][/table]now basically I want it to take each module and create that table to where it has the module name ie. Header at the top of the table and all menu items that are a child to that module in the second row . then i want th single blank row just for style purpouse before it moves on to do the same thing with the next module. Im assuming the best way to do this is with an array and all though i have a basic understanding of what the array does i havent got a clue how to use it and reading the php bible to figure it out is just confusing me so im hoping some one can show me a simple example that i can work off of or if im wrong and going about this all wrong smack me around a bit and get me set strait. any help is greatley apreciated.. Tripic Quote Link to comment https://forums.phpfreaks.com/topic/36023-solved-dynamic-menu/ Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 This wont setup the tables how you want, but it should give you a good start.[code]<?php // connect to db. $sql = " SELECT mods.modname AS mname, child.childname AS cname FROM mods,child WHERE mods.id = child.modid;"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $mname = ''; while ($row = mysql_fetch_assoc($result)) { if ($row['mname'] != $mname) { $mname = $row['mname']; echo "<h1>$mname</h1><br />"; } echo $row['cname']."<br />"; } } } else { echo "Query failed ".mysql_error(); }?>[/code]If you really need help setting up the tables you'll need to be a little clearer with your explination sorry. Quote Link to comment https://forums.phpfreaks.com/topic/36023-solved-dynamic-menu/#findComment-170940 Share on other sites More sharing options...
Tripic Posted January 28, 2007 Author Share Posted January 28, 2007 Cool i will give this a shot i think i know what to do for the tables its just getting the header got each module to only list once each and get the menu links to list all of the recors that are a child to the module above it Quote Link to comment https://forums.phpfreaks.com/topic/36023-solved-dynamic-menu/#findComment-171286 Share on other sites More sharing options...
Tripic Posted January 28, 2007 Author Share Posted January 28, 2007 ok right now its poping up the module name for each menu item so the module name keeps coming up over and over i only want it to sho up once hers a pic so you can see what its doing now [URL=http://img236.imageshack.us/my.php?image=example1nm4.jpg][IMG]http://img236.imageshack.us/img236/5189/example1nm4.th.jpg[/img][/URL]heres the modified vertion of your code that i adapted to get it to work like this[code]<?php require_once('../Connections/TEst.php'); ?><?phpmysql_select_db($database_TEst, $TEst);?><?php // connect to db. $sql = " SELECT brg_modules.Module_Name AS mname, brg_menu.title AS cname, brg_menu.icon AS cimg, brg_menu.url AS curl FROM brg_modules,brg_menu WHERE brg_modules.id = brg_menu.module;"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $mname = ''; while ($row = mysql_fetch_assoc($result)) { if ($row['mname'] != $mname) { $mname = $row['mname']; $cname = $row['cname']; $curl = $row['curl']; echo "<table><tr><td>$mname</td></tr>"; } echo "<tr><td><ahref='$curl'>$cname</a></td></tr><tr><td> </td></tr></table>"; } } } else { echo "Query failed ".mysql_error(); }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/36023-solved-dynamic-menu/#findComment-171362 Share on other sites More sharing options...
Tripic Posted January 29, 2007 Author Share Posted January 29, 2007 this isnt resolved Quote Link to comment https://forums.phpfreaks.com/topic/36023-solved-dynamic-menu/#findComment-172027 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.