Results 1 to 3 of 3

Thread: create a menu

  1. #1
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default create a menu

    Hi, I hope anyone can help me out. I need to create a menu as the the syntax below.

    Category (HUMAN)
    subCategory1 (Man)
    subcategory2 (Girl)
    ... .... ... ....

    Category2 (FRUITS)
    subCategory1 (Mango)
    subCategory2 (Apple)
    ... ....

    I am not using any javascript code, only php and database which is storing the details. I'll be very grateful if you can help me out. I spend too much time trying to do that. thanks in advance

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    My idea failed, sorry.
    Last edited by Nile; 06-18-2008 at 06:45 PM.
    Jeremy | jfein.net

  3. #3
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    What does the table look like?

    To make the menus nicer than plain HTML, you might also consider having PHP produce Javascript to produce dropdown menus.

    EDIT: Try something like this:

    Code:
    $rows = MySQL_Query("SELECT DISTINCT catagory FROM `mypages` ");
    while($row = MySQL_Fetch_Array($rows)){
    	$contents .= '<div>Catagory ('.$row['catagory'].')</div>';
    	$rows2 = MySQL_Query("SELECT subcatagory FROM `mypages` WHERE catagory = \"".$row['catagory']."\"");
    	while($row2 = MySQL_Fetch_Array($rows2)){
    		$contents .= '<div>Subcatagory ('.$row2['subcatagory'].')</div>';
    	}
    }
    print $contents;
    If your table is like this:
    Code:
    catagory  | subcatagory
    --------------------------
    Cat 1     | subcat 1
    Cat 1     | Subcat 2
    Cat 2     | subcat A
    Cat 2     | subcat B
    The output will look like:
    Code:
    Catagory (Cat 1)
    Subcatagory (subcat 1)
    Subcatagory (subcat 2)
    Catagory (Cat 2)
    Subcatagory (subcat A)
    Subcatagory (subcat B)
    Last edited by Jas; 06-20-2008 at 06:43 PM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •