this script is a modification of a solution i was given for a similiar problem
http://vbforums.com/showpost.php?p=2323616&postcount=7
What im trying to do now... is list a table. The table is full of Links and menu's.
This is how im trying to have it outputted.
Navigation minRank: 0
Home minRank: 0
Members minRank: 0
Console minRank: 1
Forums minRank: 0
Downloads minRank: 1
All minRank: 1
Images minRank: 1
Exe minRank: 2
Zip minRank: 1
This is the script as it is currently. This is also confusing the ***** outa me and i dont know why.
Also this is my database table:PHP Code:$sql = "SELECT * FROM navigation_links WHERE menu_id = -1";
$result = mysql_query($sql) or die(mysql_error());
$menus = array();
while($row = mysql_fetch_array($result)) {
$menus[] = $row;
}
//Tryed this to see if it'd work.
foreach($menus as $menu){
$sql1 = "SELECT * FROM navigation_links WHERE menu_id = '".$menu['link_id']."'";
$result = mysql_query($sql1) or die(mysql_error());
$links = array();
while($row1 = mysql_fetch_array($result)) {
$links[$row1['menu_id']][] = array('id' => $row1['link_id'],
'name' => $row1['link_name'],
'url' => $row1['link_url'],
'minRank' => $row1['minRank']);
}
}
foreach($menus as $menu) {
echo'
<div class="forum">
<span class="name"><font color="orange">Menu :'. $menu['link_name'].'</font></span>
<span class="description"> minRank:'.$menu['minRank'].'</span><br />
<span class="mods">Menu Links:';
//*
foreach($links[$menu['id']] as $link) {
echo 'Mod:'.$link['link_name'].' : '.$link['link_url']. ' : '.$link['minRank'];
}
//*/
echo'</span></div><br />';
}
The problems i had... Were either all links and nav's would show.Or just nav's would show. Depending on what i changed in the query.PHP Code:CREATE TABLE `navigation_links` (
`link_id` tinyint(3) NOT NULL auto_increment,
`link_url` varchar(50) NOT NULL default '',
`link_name` varchar(50) NOT NULL default '',
`menu_id` tinyint(21) NOT NULL default '0',
`minRank` int(11) NOT NULL default '0',
`disabled` int(11) NOT NULL default '0',
PRIMARY KEY (`link_id`)
) TYPE=MyISAM AUTO_INCREMENT=34 ;
Help is much needed and apperciated.
EDIT:: RESOLVED
Solution::
it was this query that made it happen.PHP Code:$sql = 'SELECT * FROM navigation_links WHERE menu_id= -1';
$result = mysql_query($sql) or die(mysql_error());
$forums = array();
while($row = mysql_fetch_array($result)) {
$forums[] = $row;
}
$sql1 = "SELECT nav.*, nav2.* FROM navigation_links nav JOIN navigation_links nav2 ON nav2.menu_id = nav.link_id";
$result = mysql_query($sql1) or die(mysql_error());
$moderators = array();
while($row1 = mysql_fetch_array($result)) {
$moderators[$row1['menu_id']][] = array('url' => $row1['link_url'], 'name' => $row1['link_name']);
}
foreach($forums as $forum) {
?>
<div class="forum">
<span class="name"><?php echo $forum['link_name']; ?></span>
<span class="description"><?php echo $forum['link_url']; ?></span>
<span class="mods">Moderators:
<?php
foreach($moderators[$forum['link_id']] as $mod) {
?>
<a href="userinfo.php?id=<?php echo $mod['url']; ?>"><?php echo $mod['name']; ?></a>
<?php
}
?></span>
<?
}
PHP Code:$sql1 = "SELECT nav.*, nav2.* FROM navigation_links nav JOIN navigation_links nav2 ON nav2.menu_id = nav.link_id";
Check That...maybe NOt.




Reply With Quote