Is it possible to have dynamic data extracted from a database, displayed as menu items

Is it possible to have dynamic data extracted from a database, displayed as menu items

Is it possible to have dynamic data extracted from a database, displayed as menu items
divider

Yes, it is possible.

Follow the steps as detailed below:

  • Create your menu as usual
  • Create the record-set that you want to display in the menu
  • Change to "Code View" and search for the lines where you want the dynamic table to appear

The code should look similar to this

<li> <a href="#" title="Product Articles">Articles</a>
      <ul>
            <li> <a href="#" title="MX CSS Menus">MX CSS Nenus</a></li>
      </ul>
</li>
  • Now create the repeat region

The code should look similar to this

<table border="0" cellpadding="0" cellspacing="0">
      <tr>
            <td>prod_id</td>
            <td>prod_name</td>
      </tr>
      <?php do { ?>
      <tr>
            <td><?php echo $row_rs_products['prod_id']; ?></td>
            <td><?php echo $row_rs_products['prod_name']; ?></td>
      </tr>
      <?php } while ($row_rs_products = mysql_fetch_assoc($rs_products)); ?>
</table>
  • Now delete all the tags that has something to do with the table

It should then look like this

      <?php do { ?>
            <?php echo $row_rs_products['prod_name']; ?>
      <?php } while ($row_rs_products = mysql_fetch_assoc($rs_products)); ?>

You now have a "table-less" dynamic table

  • Now simply integrate this into your menu

It could look something like this

<li> <a href="#" title="Products Articles">Articles</a>
      <ul>
            <?php do { ?>
                  <li> <a href="../forum.php?pro_id=<?php echo $row_rs_products['prod_id']; ?>" title="<?php echo $row_rs_products['prod_name']; ?> Forum"><?php echo $row_rs_products['prod_name']; ?></a> </li>
            <?php } while ($row_rs_products = mysql_fetch_assoc($rs_products)); ?>
      </ul>
</li>
Written by:  - 6 Sep, 2009