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
Step One
Before creating a PHP DHTML menu, please make a database including the product categories and the specific products:
- Create a database named "dmenu" and a database user named "duser" in mySQL
- Set the password as 123
- 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)
);
- 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.
Next, click Menu Item > Condition, and input the prefix and suffix there.
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.
Click Menu Item > Condition, and input the prefix and suffix there.
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.
Click here for the PHP menus ample
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:
As to the source code of the PHP drop down menu, please check the details here.
-
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.
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.
Guides
- How to create drop down menu?
- How to create a PHP drop down menu?
- How to make effective navigation bar for your website?
- How to create a stunning and effective drop-down menu?
- 30 simple but effective jquery drop down menu
- 50 beautiful and user-friendly web menus
- How to make your JavaScript menu search engine friendly?
- Drop down menu script VS drop down menu builder
- How to add a dropdown menu to HTML page?
- How to position a drop down menu in webpage?