PHP Drop Down Menu, the ultimate PHP drop down menu builder

How to Create a PHP Drop Down Menu?

How to create a PHP drop down menu? The tutorial below shows the operating steps from mySQL database to complete a PHP DHTML menu, here we take Sothink DHTML Menu for example, and please have a check.

Setps to create PHP drop down menu

Sample of PHP drop down menu

 

Step One

Before creating a PHP DHTML menu, please make a database including the product categories and the specific products:

  1. Create a database named "dmenu" and a database user named "duser" in mySQL
  2. Set the password as 123
  3. Generate tables with codes below:

    CREATE TABLE Category (
    CID int(11) NOT NULL auto_increment,
    Name char(255) DEFAULT '' NOT NULL,
    Notes char(255),
    PRIMARY KEY (CID)
    );
    CREATE TABLE Product (
    PID int(11) NOT NULL auto_increment,
    CID int(11),
    Name char(255) DEFAULT '' NOT NULL,
    Link char(255),
    Notes char(255),
    PRIMARY KEY (PID)
    );


  4. Add a few records to the tables.

 

Step Two

Create a new menu with Sothink DHTML Menu, click Menu Item > General, select HTML and input <?=$CatName?> in the context box.

PHP Drop Down Menu

Next, click Menu Item > Condition, and input the prefix and suffix there.

PHP Drop Down Menu

NOTE: Please uncheck "Preview > Enable Auto-Refresh" when creating PHP drop down menus, or you may get a warning because it is the server-side condition code which cannot be processed by the browser directly, but it won’t happens for the PHP drop down menu in a sever-supported PHP page
Tips: To prevent the error popping up, please add the JavaScript comment delimiters /* and */ to Prefix and Suffix:

Prefix:

/*
<?
for ($i = 0; $i < $numrowsCat; $i++)
{
$rowCat = mysql_fetch_array($resultCat);
$CatName = $rowCat["Name"];
?>
*/

Suffix:

/*<?
}
?>
*/

Step Three


Add a sub item, set it as HTML and input <?=$ProName?> in the box, next, input <?=$Link?> in Link field.

PHP Drop Down Menu

Click Menu Item > Condition, and input the prefix and suffix there.

PHP Drop Down Menu

Note: Please do check "This item may be invisible at run-time" when creating the PHP drop down menu, otherwise, the property code would not be referenced and the whole PHP drop down menu would not work correctly.

Sample for a PHP Menu

Click here for the PHP menus ample

PHP Drop Down Menu

Observe the PHP menu above, which contains two levels: the parent level showing the product categories and the sub level showing the specific products. Actually, only two menu items are in the PHP drop down menu: one is in the parent level and the other in the sub level.

The final result for the PHP menu is just got from database:

PHP Drop Down Menu

As to the source code of the PHP drop down menu, please check the details here.

  • Sothink DHTML Menu
  • DHTML Menu

  • - Navigate website clearly by drop down menu
  • About Sothink DHTML Menu

    DHTML Menu is an easy-to-use navigation bar maker. It can create SEO friendly drop down menu, JavaScript menu and naviation bar for website in few minutes. For beginner, build professional navigation bar from built-in templates and preset styles; for expert, fully custmize the drop down menu. The best navigation bar is prodoced by DHTML Menu.

  • Download Sothink DHTML Menu
  • Buy Sothink DHTML Menu
Sothink DHTML Menu

 

 100% Clean - No need to worry about installing unwanted spyware or adware. Uninstallation is completely supported.
 Life-time Free Support - Send an email to our customer service team at support@sothink.com whenever you need help.
 Risk Free Guarantee - Shop safely in our secure online store. Your data and personal information are protected.

Sothink ist das Markenzeichen von SourceTec Software Co., LTD.
Flash ist das Markenzeichen von Adobe.
Sothink Software: SWF Decompiler, DHTML Menü, Baum Menü, JavaScript Web Scroller, SWF Quicker, SWF Easy, Quicker für Silverlight, Logo Maker

Verbindungen Kommentar Datenschutz AGB Sitemap