Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:20

A solution for ordering menu items in php / mysql


Poster: mlovelock
Dated: Friday March 28 2008 - 1:16:20 GMT

I recently needed to alter the order in which menu items were displayed when pulled out of a mysql database, but couldn't find a solution here on the forums, so I did the following, thought it might be of use to someone:

To my mm_items table, I added the field 'itemorder' (tinyint, or smallint, default = 1 - note this default will place a new item at the front/top of a menu, to place at the bottom, you could use an arbitrary value, say 99 or something)

To mm_phpmenu.php I changed line 323 from this:
Code:
      $query="select * from ".$table_prefix."items where menuid=$mar[menuid]";

to this:
Code:
      $query="select * from ".$table_prefix."items where menuid=$mar[menuid] order by menuid asc, itemorder asc";


It then orders and displays (in ascending order) all menu items according to the 'itemorder' value. It's not rocket science and I'm sure anyone with an ounce or two of mysql/php knowledge has probably already done it, but just thought it might be useful to someone.

Note, I don't think the ordering by menuid is strictly necessarry, but it's just tidy.

Michael.

Re: A solution for ordering menu items in php / mysql


Poster: Ruth
Dated: Friday March 28 2008 - 3:35:55 GMT

Thank you very much for posting this information. I sure appreciate any help here on the forum :)

Ruth