CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.

YesSoftware Forums -> CodeCharge -> Tips & Solutions

 MySQL dynamic menu trick

Print topic Send  topic

Author Message

Posts: 1
Posted: 10/12/2016, 11:31 AM

So, I had a basic horizontal menu, being driven by a MySQL table. Pretty simple to do.

But, I suddenly had an issue, where files uploaded (another page) that push their names and a description to another table, had to become part of the menu. This was in 2 places (that is 2 types of uploaded files, in terms of their general category.)

So, I engineered a SQL query for the menu, that makes the files and their links show up, dynamically.

The main menu table is still used, and the query forges the other choices. I sometimes use Active as a integer flag to choose things I want to turn off and on as features. This can be useful in building things, or letting users turn on and off things.

I replaced the query to the table, with this sql query in the menu object on the page. It makes it's own Id numbers, so you have to set up your actual Menu table so that the first part of the sequence agrees with these dynamically assigned numbers. After that, the forging in the sub-queries manages to lie to the menu, and give it what you want. In this case, the uploaded file descriptions and the links to the targets.

select @r := @r+1 as Id, z.* from(

SELECT Menu, Link, Level, Tier, Active


SELECT Menu, Link, Level, Tier, Active FROM (

Description as Menu,
CONCAT("documents/",Link) as Link,
3 as 'Level',
1 as Tier,
1 as Active
FROM Documents
ORDER BY Description) x


SELECT Menu, Link, Level, Tier, Active FROM (
Description as Menu,
CONCAT("profiles/",Link) as Link,
4 as 'Level',
1 as Tier,
1 as Active
FROM Profiles
Order by Description) y

)z, (select @r:=0)y;

View profile  Send private message

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

Web Database

Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright 2003-2004 by  and YesSoftware, Inc.