PHP Nested Loop for site Navigation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eaddudley
    New Member
    • Feb 2010
    • 7

    PHP Nested Loop for site Navigation

    Hello
    I would like to create a nested Navigation list for my shopping cart.
    Ex. Our Products - Pepper Spray, Stun Guns, Tasers, Hidden Cameras. I would like to store Categories, and page name in my database. So I would like Pepper Spray, Stun Guns, Tasers, Hidden Cameras to be hidden until a site visitor click on Our Products to show its pages. And when Pepper Spray is clicked on its products display. Please Help
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    have a look at the Suckerfish Dropdown

    Comment

    • eaddudley
      New Member
      • Feb 2010
      • 7

      #3
      I visited the site you suggested but it does not deal with getting page title from the database in order to make them dynamic. As another example on the site that you suggested its navigation bar drops down when a user click on CSS for beginners.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by eaddudley
        I visited the site you suggested but it does not deal with getting page title from the database in order to make them dynamic.
        Suckerfish Dropdown is about HTML, not about how to code that in any programming language. but if you know, what the output should look like, it’s not that hard anymore to code the rest.

        as example, I create my SFDD by means of XSLT …

        Comment

        • eaddudley
          New Member
          • Feb 2010
          • 7

          #5
          I would like to use php mysql and dreamweaver to make this dynamic drop down navigation menu.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            first you need a concept, how to get the data from DB into the desired HTML.

            Comment

            • eaddudley
              New Member
              • Feb 2010
              • 7

              #7
              Do you know how to do it or not sir. because I'm just going in circles

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                that strongly depends on your DB structure, which I don’t know.

                Comment

                • eaddudley
                  New Member
                  • Feb 2010
                  • 7

                  #9
                  I've set up a database, I have two table, subjects and pages. In the pages i have
                  id - 1
                  subject_id - 1
                  page_name - Pepper Spray
                  position - 1
                  visible - 1
                  content - This is our pepper spray page

                  and in the subjects i have
                  id - 1
                  menu_name - products
                  position - 1
                  visible - 1

                  How should the sql statement read in order to get a nested list with the pages under subject.

                  Product
                  Pepper Spray
                  Stun Guns

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    what exactly is the menu structure, you desire?

                    Comment

                    • eaddudley
                      New Member
                      • Feb 2010
                      • 7

                      #11
                      I would Like to have a navigation That has three links, Products, Polices, FAQ. So that when a customer clicks on Products it expands and show Its products such as Pepper Spray, Stun Guns, Tasers, Hidden Cameras. and the polices would have Private, Return.

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        so essentially, all you need to do is populate the "products" dropdown with values from the DB, since all the oher links seem fixed.

                        that is, as a coarse course of action, you need to fetch the page_name and subject_id (or whatever is your primary index) and convert it into a list.
                        Code:
                        // for each product in `pages`
                        <li><a href="product.php?id={subject_id}">{page_name}</a></li>
                        as of personal preference, I’d recommend PDO for DB handling.

                        will you need help with the SQL? is the `content` in `pages` HTML code you can insert?

                        Comment

                        • eaddudley
                          New Member
                          • Feb 2010
                          • 7

                          #13
                          You're not helping me man. I'm getting no where with you. I bet you don't even know what I trying to make. It's like you're dense right now.

                          Comment

                          Working...