PHP Tutorial: Menu - Sub Menu in PHP/ MySQL

PHP Tutorial: Menu - Sub Menu in PHP/ MySQL


Hello everyone. This is a short tutorial about menus and sub menus in PHP / MySQL. Sorry for my horrible English :) I haven't spoken English since ever. Feel free to mute the audio if you want and watch the video instead :) . If you like this video, please like, rate, comment. Enjoy and thanks for watching....


Source Code:
http://www.freefilehosting.net/phpmys...

Drop Down Menu List Script:
http://css-tricks.com/simple-jquery-d...
Closed Caption:

hello everyone my name is Andrea and I'm
going to make a tutorial about how to
create menus and submenus with PHP in my
sequel so it would look like this one
here more or less so not exactly but you
get the idea so this service here is the
route the menu and these other ones here
are the submenus and this below this
office support here are the submenus of
this office support this is of course
this is just an example these are not
real categories so let's go ahead and
create a database people have already
created a database called testings on my
server hdmi had been my sequel i'm going
to call it menus
ok man you gonna have three columns will
call the first one ID integer
autoincrement primary second one I'm
going to menu name varchar of 150
characters long
the last one will be called parent ID so
this is a here will be started we will
start the value of the idea of the
parent menu it will be integer like the
ID like the field ID so go ahead and
save this
then reload menus and insert some
records so the first one is going to be
home
here the value I al insured here value
of zero for me this 0 you can place
whatever you want here but for me this 0
means that this is a root menu so it is
not a doesn't have any parent category
parent menu about then she will again go
let's browse
but to make things even easier i'm going
to go to the structure and make this
parent idea i'm going to change this and
I'm going to assign it a different value
of zero so so every time that I set a
new record it will take a different
value of their side so i don't have to
input this 0 here every time
okay i'm going to actually come up and
some more menus like services and
contact
browse and voila this parent ID took the
value of zero by default so let's go
here so this is a menu that is a hand
coded in HTML
this is not very practical this might be
practical for small sites but you can
imagine that the you might want to add
or remove menus and submenus so it is
not a very good practice to delete and
edit the HTML you might screw up the
code so if this better if you control it
from the database so we're going to
create it and i'm going to create a new
file you might do it in one file if you
like going to call it functions.php this
function decoding here then I'm going to
include this file right above all of the
HTML code
functions each let's say
four zeros reload know then we're good
to go let's go to the functions and
we're going to connect to the database
I'm not going to explain how to connect
with it though the database because as
you may already know how to do that if
you are if you aren't interested in this
kind of tutorial so you already have the
knowledge how to do that connect
yeah
thanks best word
best part I just the basic PHP code then
i'm going to create a function to
display all the road or menus you call
it from the table and call this function
display menus
we're going to query the data query from
goodnight my secret error
and then we're going to check if there
is any record so if secret rose query so
if it returns greater than $OPERAND is
greater than zero so if we have any row
then we're going to do an echo URL so
you are and we're gonna close this HTML
list then between this two opening and
closing tag of the well we're gonna loop
all of the records that are stored in
our table so my secret which query
so we're going to look all of this data
that we have found in this query
variable with are starting to square
variable right here
no echo
yeah
closely in life
ok
let's see here past four hours don't
have any so I'm going to display this
function just above the HTML menu that I
created this here i'm going to paste it
in here let's see America ok so it's not
styled but this is enough to see that we
are verrakai we're getting all the
records from the database and displaying
them correctly so I'm going to collapse
a little bit of code right here because
too long and it's occupying all of my
screen display menus but now what I want
to do is I want to get with the same
function
I want to get even the submenus and
check if there is any sub menu for each
of these menus so what are going to do
is first of all I will write a different
and different value right here i'm going
to pass a variable i'm going to call it
a parent ID and i'll give a different
value of zero so this parent ID here i'm
going to call it gonna go where parent
ID so we're parent ID is equal to this
parent idea so for the moment what we're
seeing now is where the parent id0 let's
go ahead and fresh with you know all of
these functions of this sorry this menu
because all of these menus have the
parent idea of 0 so doesn't have any
parent menu as we can see what we're
going to do is we're going to list some
services below this service services
menu so let's insert not i'm going to
call the first let's see if it isn't
with ID 3 i'm going to cover this idea
i'm going to insert services let's say
for example online services
for the moment i'm going to make it 0n
services and let's see
Family Services let's go ahead and then
the crowd we can see that these are all
Allah all in the same line refresh the
three llow we see that this to online
services and family services are equal
to these other menus also because they
don't have any parent category that
parent IDs set to 0 but now what I want
to do is this two menus I want to
display them below this services menu so
these here are going to be submenus to
this service is here so this menu
services here so let's go ahead and
change the value of this parent ID value
of this to these two last menus so
this tree because it was three
see now this idea of services because it
becomes the parent ID value and this one
too
added 3 now now if you go here and
refresh the page you can see that this
to last menus will disappear from the
screen because here we said that it will
display the rows where the parent ID is
equal to this parent ID which has the
value with which are the different value
of zero so this is working very well now
what we want to do is display those two
below the services and how we're going
to do that this we're gonna break this
code right here
I call this below and that and then i'm
gonna go i'm going to do a very very
simple code i'm going to copy this
display menu menus and I'm gonna call
the function itself inside the function
itself but this parent ID now from zero
will keep them will get the value of Rho
ID so now is going to check
each time
let's make it a little
ID
so for a moment let me wrap yourself
reload now what is going to do right now
is is going to check is going to solve
the function will call itself and is
going to check if there is any row with
a value of Rho ID of this that this
apparent that we will be equal with this
world why do so let's go ahead and paste
this save refresh and voila
everything is working fine as you can
see this never display the submenus of
these services but this is just a simple
to operate this is just one level but if
you like you can make it whatever level
or you like there are no limitations on
doing this for example i will take this
idea of 5 online services i'm going to
make going to create another menu
i'm going to call it for the names are
not important
five
55
cool
Avila you see you don't have now you
don't have to code every time that you
want to change everything now to code
the HTML but you have to do is just add
the new eight about new row or new menu
whatever you want to call it in the
database and the records will be
displayed with beer in that as HTML
right here so
what we're going to do now is just for
the sake of a tutorial to make this menu
look more like this one right here is
what i'm going to do is I'm gonna
comment all of this menu HTML menu out
I'm gonna cut this display menu from
here and i'm going to paste it right
below this commented HTML menu I'm going
to refresh and as you can see this works
more or less looks more or less like
this example right here now we could add
for example links like age
hey Trev right here and then close it
for example right here
sorry about that
I don't know what's happening let's
fresh ok
so
this is a common link doesn't take you
anywhere
ok now these are all links so assuming
that you have actual pages right here
so the chip this is a very simple way
you can extend it even further
I hope this helps you for I don't
encoding PHP or making you websites so
thanks for watching

Video Length: 18:13
Uploaded By: TheEndritv
View Count: 30,522

Related Software Products
Tree Menu
Tree Menu

Published By:
SourceTec Software

Description:
Tree menu builder allows you to create JavaScript navigation menu for a complicated directory website. This menu tree builder supports most browsers on various OS, including IE 9 Beta and Windows 7. It works with HTML editors as add-ins, such as Dreamweaver, Expression Web, FrontPage and Golive. With Sothink Tree Menu, you can create fast-loading menu tree, cross-browser web menu in clicks; build functional tree menus like highlight tree menu, iPad tree menu and tree menu with playing sound are ...


Related Videos
Skinny Menu
Skinny Menu

This is a surefire way to keep the pounds off! Watch Studio C Mondays at 10pm ET/8pm MT on BYUtv. Watch full episodes of Studio C online here: http://byutv.org/studioc Like Studio C on Facebook: https://www.facebook.com/StudioCtv hr / bClosed Caption:/b HEY THANKS FOR TAKING ME OUT TO LUNCH, MAL. OH, PLEASE, I LOVE SPENDING SMALL AMOUNTS OF TIME WITH MY SISTER. I'M JUST TRYING TO EAT HEALTHIER, YOUbr ...
Video Length: 03:13
Uploaded By: Studio C
View Count: 1,609,995

Creating a Slide-In Menu in Android - Part 1: Showing the Menu
Creating a Slide-In Menu in Android - Part 1: Showing the Menu

Read Cyril Mottier's blog on his design: http://cyrilmottier.com/2012/05/22/th... http://cyrilmottier.com/2012/05/29/th... http://cyrilmottier.com/2012/06/08/th... Grab the code for this example on GitHub: https://github.com/jaylamont/AndroidF... hr / bClosed Caption:/b hi everyone this is the start of a series of videos describing how you can implement a fly-in menu in an Android application serial mortier on his blogbr ...
Video Length: 17:12
Uploaded By: Jay Lamont
View Count: 167,599

Bootstrap Tutorial for Beginners - 10 - Sidebar Menu
Bootstrap Tutorial for Beginners - 10 - Sidebar Menu

Facebook - https://www.facebook.com/TheNewBoston-464114846956315/ GitHub - https://github.com/buckyroberts Google+ - https://plus.google.com/+BuckyRoberts LinkedIn - https://www.linkedin.com/in/buckyroberts reddit - https://www.reddit.com/r/thenewboston/ Support - https://www.patreon.com/thenewboston thenewboston - https://thenewboston.com/ Twitter - https://twitter.com/bucky_roberts hr / bClosed Caption:/b are ready guys ...
Video Length: 12:23
Uploaded By: thenewboston
View Count: 70,700

JavaScript CSS Custom Drop Down Menu System Tutorial Validated HTML5
JavaScript CSS Custom Drop Down Menu System Tutorial Validated HTML5

Tutorial for creating custom JavaScript and CSS drop down menu systems for your website. Exploring Javascript functionality to render special behaviors in our drop down list menus. Pure CSS menus are king but JavaScript in the mix is fun too, why not play! hr / bClosed Caption:/b hello my good friends today I'm going to explain a menu system and then share the code with you guys first let's take a look at the script in action so you can see what ...
Video Length: 22:14
Uploaded By: Adam Khoury
View Count: 58,020

[PS3/MW3] Tree Patch Mod Menu Remake + Download
[PS3/MW3] Tree Patch Mod Menu Remake + Download

Copyright Disclaimer Under Section 107 of the Copyright Act 1976, allowance is made for "fair use" for purposes such as criticism, comment, news reporting, teaching, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favor of fair use. [MW3/PS3] Tree Patch Remake + Download! ________________________________________­____________ Hey guys! This is Sticky's ...
Video Length: 03:16
Uploaded By: {NM}// Thanks for 3.000 Subs \\{NM}
View Count: 42,711

Create a Drill Down Menu in Excel (1) - Cascading Drop Downs
Create a Drill Down Menu in Excel (1) - Cascading Drop Downs

Find me on Twitter here: https://twitter.com/MattPaul25 Part 2: http://www.youtube.com/watch?v=4k_8ZS6q6BI&feature=plcp Here is the sample data: http://www.contextures.com/xlSampleData01.html This is my idea of what a 'drill down menu' is. Some people may have a different interpretation as to what the term 'drill down' means. Honestly, it's somewhat vague. However - in my opinion drilling down on data, has a connotation of digging deeper / ...
Video Length: 14:51
Uploaded By: Matt Paul
View Count: 39,129

Ori and the Blind Forest - Main Menu Theme [Piano transcription]
Ori and the Blind Forest - Main Menu Theme [Piano transcription]

Piano sheets and download at https://echovariation.wordpress.com/2... This theme fits the game so well. I want to do another song from this game since the entire OST is too good. Please leave your vote for which song in the comments ;) Light of Nibel/Restoring the light, Facing the Dark (they are very similar) IIIII (Done) Completing the circle IIII (WiP) The Spirit Tree IIII (Done) Naru Embracing the Light IIII The Sacrifice I Home of gumon ...
Video Length: 02:02
Uploaded By: Echo Variation
View Count: 32,578

- Innovation- Pine Tree V2.5 Mod Menu DOWNLOAD
- Innovation- Pine Tree V2.5 Mod Menu DOWNLOAD

read below how to get it all credits ihax xex seya soon guys [ buy from creator ] http://www.youtube.com/user/iHaxXeX
Video Length: 03:22
Uploaded By: Ennzyma
View Count: 20,651

Watch Dogs Unreleased Track - Skill Menu Ambient
Watch Dogs Unreleased Track - Skill Menu Ambient

Composer - Brian Reitzell. Recorded from the game. All rights are go to their respective owners. Playlist: http://www.youtube.com/playlist?list=...
Video Length: 06:47
Uploaded By: Pavel Chistov
View Count: 18,863

Navigation Control : Tree View  and Menu in Asp.net using C#
Navigation Control : Tree View and Menu in Asp.net using C#

In this video tutorial i have tried to explain menu control and treeview control in asp.net. Generally when u searched any website you have seen menu . Now using visual studio in asp.net you can easily create menu in your application . All of its events and properties are explained in this video. Treeview : Treeview is also one type of navigation control by which you can redirect your page from one page to another. When you visit some sites or blogs you can see at right or ...
Video Length: 07:42
Uploaded By: Dhruvin Shah
View Count: 15,023

Copyright © 2025, Ivertech. All rights reserved.