You are on page 1of 3

Login

<h2>Login</h2>
<form action="login.php" method="post">
<table>
<tr>
<td>Username:</td>
<td><input type="text" name="username" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="login" value="LOGIN" /></td>
</tr>
</table>
</form>

Source code of menu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html>
<head>
<title>CSS Menu Dinamis dengan PHP</title>
<style>
.menubar{
display:block;
height:38px;
background:#000
}
.menubar ul{
margin:0;
padding:0;
list-style:none;
z-index:99999;
}
.menu a,.menu a:visited{
display:block;
text-decoration:none;
padding:10px 18px;
position:relative;
z-index:99999;
}
.menu{
vertical-align:top;
display:inline-block;
}
.menu li{
position:relative;
z-index:99999;
}
.menu>li{
float:left;
}
.menu li>a,.menu li>a:visited{
color:#fff;
font-weight:bold;
background: #00009e;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
}
.menu>li:hover>a{
background: #008800;
}
.menu li li>a:hover{
color:#fff;
background:#00009e;
}
.menu li li a{
background: #008800;
color:#fff;
}
.menu li:hover li a{
font-weight:normal;
}
.menu ul{
position:absolute;
white-space:nowrap;
z-index:99999;
left:-99999em;
margin-top:0px;
}
.menu>li:hover>ul{
left:auto;
min-width:100%;
}

body{font-family:arial;font-size:13px;color:#444;background:#eee}
.wrapper{width:900px;margin:auto}

</style>
</head>
<body>
<div class="wrapper">
<div class="menubar">
<ul class="menu">
<?php
// koneksi
$mysqli = new mysqli('localhost', 'root', '', 'mydb');

// ambil menu utama
$res = $mysqli->query("SELECT idmenu,menu,link from menu where
sub='0'");
while($menu = $res->fetch_array(MYSQLI_ASSOC)){
// tampilkan sub menu kalau ada
$res2 = $mysqli->query("SELECT idmenu,menu,link from menu where
sub='$menu[idmenu]'");
$num = $res2->num_rows;
echo " <li><a href=\"$menu[link]\">$menu[menu]</a>";
if($num>0){
echo "\n <ul>\n";
while($sub = $res2->fetch_array(MYSQLI_ASSOC)){
echo " <li><a href=\"$sub[link]\">$sub[menu]</a></li>\n";
}
$res2->free_result();
echo " </ul>";
}
echo "</li>\n";
}
$res->free_result();
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
?>
</ul>
</div>
</body>
</body>
</html>

You might also like