Hello Everyone,

I am a newbie and have been reading, experimenting, and building a 
database driven website about my favorite topic...beer.

I am trying to create a database driven navigation menu that only 
displays certain menu options according to their authority.  I have 
been receiving a little help from a friend at work but it is the 
weekend and I am still in need of help.

My code displays the menu but I don't know how to get teh 
MenuSelectionName items to be hyperlinks.

Below is the code and the tables I am using.  Your help will be 
greatly appreciated.

Stephen

Here is what I would like to appear...

Menu
MenuTopic
  MenuSelectionName
  MenuSelectionName
MenuTopic
  MenuSelectionName
MenuTopic
  MenuSelectionName
  MenuSelectionName

It would look like this on the site...

Education
  Brewing 101
  Tasting How To
Members Only
  Add a Beer
Administration
  Add A Beer Verification
  Member Accounts Screen

Here is the code I am having a problem with...

<?php


 include("Hops.inc");                                  
                                       
      $connection = mysql_connect($host, $user,$password) 
               or die ("Couldn't connect to server.");
      $db = mysql_select_db($database, $connection)
               or die ("Couldn't select database."); 

$query = "SELECT  MenuTopic, MenuSelectionName, MenuURL, 
MenuAuthLevel FROM MenuTable ORDER BY MenuAuthLevel";
$result = mysql_query($query) or die ("Query failed");


/* creates an empty array called $menu. */
        $menu = array();


        if( $result )
        {
                while ($row = mysql_fetch_row($result))
                {
                       if( $menu[ "$row[0]" ] == null )
                        {
                                $urls = array();
                        }
                        else
                        {
                                $urls = $menu[ "$row[0]" ];
                        }
                        array_push( $urls, $row[1] );
                        $menu[ "$row[0]" ] = $urls;
                }
        }
        

        else
        {
                print "Mysql error: " . mysql_error($result);
        }


        foreach( $menu as $category => $value )
        {
                print "$category\n";
                echo "<br>"; 
                foreach( $value as $url )
                {
                        echo "&nbsp;&nbsp;&nbsp;";
                        print "\t$url\n";
                echo "<br>";  
                }
        }
?>


Tables

MenuTable

MenuID                  INT(3)                  NOT NULL 
AUTO_INCREMENT,
MenuSelectionName       VARCHAR(50)             NOT NULL,
MenuURL                 VARCHAR(50)             NOT NULL,
MenuTopic               VARCHAR(25)             NOT NULL,
MenuAuthLevel           INT(2)                  NOT NULL,


Members

FirstName               VARCHAR(50)             NOT NULL,
LastName                VARCHAR(50)             NOT NULL,
CreateDate              DATETIME                NOT NULL,
Street                  VARCHAR(50),
City                    VARCHAR(50),
State                   CHAR(2),
Zip                     CHAR(10),
Email                   VARCHAR(50),
UserID                  VARCHAR(20)             NOT NULL,
Password                CHAR(15)                NOT NULL,
PasswordHint            VARCHAR(100)    NOT NULL,
PasswordHintAns VARCHAR(50)             NOT NULL,
Authority               CHAR(2)         Default "2",










Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php-list/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to