Dynamic Menu CSS - PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Angelos

    Dynamic Menu CSS - PHP

    Hello there...
    I am trying for a long time now, to find a way of creating a dynamic drop
    down menu. I have the CSS part ready and working and also I have the first
    level of the menu working.
    the problem I have is how can I submit the id from the first level menu in
    order to make the query and create the second level and so on menu.

    I am trying to avoid Javascript but I can't see another way at the moment...
    What I want to achieve is to produce the menu on HOVER if that is not
    possible on click will be ok as well.
    Do any of you have an idea ?

    This is the code I have :
    *************** *************** *************** *
    <div id="menu">
    <ul>
    <li><h2>Product s</h2>
    <ul>
    <?php do { ?>
    <li><a href="?cat_id=< ?php echo
    ($row_product_c ategories['prod_category_ id']); ?>"title="<?ph p echo
    strtoupper($row _product_catego ries['prod_category_ name']); ?>"><?php echo
    ucfirst($row_pr oduct_categorie s['prod_category_ name']); ?></a></li>
    <?php }
    while ($row_product_c ategories =
    mysql_fetch_ass oc($rs_product_ categories)); ?>
    <ul>

    <?php do { ?>
    <li><a href="index.php ?id=<?php echo ($row_products['prod_id']);
    ?>"title="<?ph p echo strtoupper($row _products['prod_name']); ?>"><?php echo
    ucfirst($row_pr oducts['prod_name']); ?></a></li>
    <?php }
    while ($row_products = mysql_fetch_ass oc($rs_products )); ?>

    </ul>
    </li>
    </ul>
    </li>
    </ul>
    </div>
    *************** *************** *************** *****


  • Angelos

    #2
    Re: Dynamic Menu CSS - PHP

    That's the URL as well to have a look



    Comment

    • Ken Robinson

      #3
      Re: Dynamic Menu CSS - PHP

      Angelos wrote:[color=blue]
      > Hello there...
      > I am trying for a long time now, to find a way of creating a dynamic drop
      > down menu. I have the CSS part ready and working and also I have the first
      > level of the menu working.[/color]

      You should really look at the article "Son of Suckerfish Dropdowns"
      http://www.htmldog.com/ptg/archives/000050.php for how to do the CSS
      [color=blue]
      > the problem I have is how can I submit the id from the first level menu in
      > order to make the query and create the second level and so on menu.
      >
      > I am trying to avoid Javascript but I can't see another way at the moment...
      > What I want to achieve is to produce the menu on HOVER if that is not
      > possible on click will be ok as well.[/color]

      You have to populate all of the levels of the menu structure at once by
      looping through each product category for the products.

      Here is my take on your code:

      <?php
      $q1 = "select * from product_categor ies";
      $rs_product_cat egories = mysql_query($q1 );
      $tmp = array(); // hold all output in a temporary array
      $tmp[] = '<div id="menu">';
      $tmp[] = '<ul>';
      $tmp[] = '<li><h2>Produc ts</h2>';
      $tmp[] = "\t".'<ul>' ;
      while ($row_product_c ategories =
      mysql_fetch_ass oc($rs_product_ categories)) {
      $prod_cat_id = $row_product_ca tegories['prod_category_ id'];
      $tmp[] = "\t\t".'<li ><a href="' . $_SERVER['PHP_SELF'] . '?cat_id='
      .. $prod_cat_id . '" title=' . strtoupper($pro d_cat_id) . '>' .
      ucfirst(strtolo wer($prod_cat_i d)) . '</a>';
      //
      // create next level of menu here
      //
      $tmp[] = "\t\t\t".'<ul>' ;
      $q2 = "select * from products where " // since I don't know your DB
      structure, I can't fill this in ...
      $rs_products = mysql_query($q2 );
      while ($row_products = mysql_fetch_ass oc($rs_products )) {
      $prod_name = $row_products['row_name'];
      $tmp[] = "\t\t\t\t".'<li ><a href="' . $_SERVER['PHP_SELF'] .
      '?id='.$row_pro ducts['prod_id']. '" title=' .
      strtoupper($row _products['prod_name']) . '>' .
      ucfirst(strtolo wer($row_produc ts['prod_name'])) . '</a></li>'; }
      $tmp[] = "\t\t\t".'</ul>';
      $tmp[] = "\t\t".'</li>';
      }
      $tmp[] = "\t".'</ul>';
      $tmp[] = '</li></ul>';
      $tmp[] = '</div>';
      echo implode("\n".$t mp)."\n";
      ?>

      Ken

      Comment

      Working...