navigatie met genestelde list, fout
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<ul id="nav1">
<li>tools
<ul><li>emcalc</li><li>colorpicker</li></ul>
</li>
<li>php</li>
<li>css
<ul>
<li>navigation
<ul><li>nav1</li><li>nav2</li></ul>
</li>
<li>albums</li>
</ul>
</li>
</ul>
<li>tools
<ul><li>emcalc</li><li>colorpicker</li></ul>
</li>
<li>php</li>
<li>css
<ul>
<li>navigation
<ul><li>nav1</li><li>nav2</li></ul>
</li>
<li>albums</li>
</ul>
</li>
</ul>
te voorschijn laten toveren, alles lukt wel, maar keb ergens een foutje gemaakt
hij maakt achter <li>php waar geen submenu is een <ul></ul> aan.
kan iemand ff helpen, ik zie het niet direct
Code (php)
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
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
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
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
<?php
function listPages3() {
// List the home page first
$level = 2 ;
$result = mysql_query("SELECT value FROM settings WHERE name='homePage'") or die(mysql_error());
$row = mysql_fetch_array($result);
$homeID = $row['value'];
// homeID = 1
$result = mysql_query("SELECT name FROM nav_0 WHERE nav0_id='$homeID'") or die(mysql_error());
$row = mysql_fetch_array($result);
$homeTitle = $row['name'];
//homeTitle = tools
$result = mysql_query("SELECT value FROM settings WHERE name='homeNavStyle'") or die(mysql_error());
$row = mysql_fetch_array($result);
$navStyleID = $row['value'];
// $navStyleID = 1
echo '<ul id="nav' . $navStyleID . '">';
echo "<li><a href='" . BASE_URL . "/index.php'>$homeTitle</a>";
// <ul id="nav1">
// <li><a href="htpp://www.domain.be/index.php </a>
if ($level == 2)
{
$result = mysql_query("SELECT nav1_id, name FROM nav_1 WHERE nav0_id='$homeID'") or die(mysql_error());
echo "<ul>";
while ($row = mysql_fetch_array($result))
{
// Do not list the home page twice
$pageID2 = $row['nav1_id'];
$pageTitle2 = $row['name'];
echo "<li><a href='" . BASE_URL . "/index.php?id=$pageID2'>$pageTitle2</a></li>";
}
echo "</ul>";
}
echo"</li>";
// List the rest of the pages
$result = mysql_query("SELECT nav0_id, name FROM nav_0") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
// Do not list the home page twice
if ($row['nav0_id'] != $homeID) {
$pageID = $row['nav0_id'];
$pageTitle = $row['name'];
echo "<li><a href='" . BASE_URL . "/index.php?id=$pageID'>$pageTitle</a>";
if ($level == 2)
{
$result2 = mysql_query("SELECT nav1_id, name FROM nav_1 WHERE nav0_id='$pageID'") or die(mysql_error());
echo "<ul>";
while ($row2 = mysql_fetch_array($result2))
{
// Do not list the home page twice
$pageID2 = $row2['nav1_id'];
$pageTitle2 = $row2['name'];
echo "<li><a href='" . BASE_URL . "/index.php?id=$pageID2'>$pageTitle2</a></li>";
}
echo "</ul>";
}
echo "</li>";
}
}
echo '</ul>';
}
?>
function listPages3() {
// List the home page first
$level = 2 ;
$result = mysql_query("SELECT value FROM settings WHERE name='homePage'") or die(mysql_error());
$row = mysql_fetch_array($result);
$homeID = $row['value'];
// homeID = 1
$result = mysql_query("SELECT name FROM nav_0 WHERE nav0_id='$homeID'") or die(mysql_error());
$row = mysql_fetch_array($result);
$homeTitle = $row['name'];
//homeTitle = tools
$result = mysql_query("SELECT value FROM settings WHERE name='homeNavStyle'") or die(mysql_error());
$row = mysql_fetch_array($result);
$navStyleID = $row['value'];
// $navStyleID = 1
echo '<ul id="nav' . $navStyleID . '">';
echo "<li><a href='" . BASE_URL . "/index.php'>$homeTitle</a>";
// <ul id="nav1">
// <li><a href="htpp://www.domain.be/index.php </a>
if ($level == 2)
{
$result = mysql_query("SELECT nav1_id, name FROM nav_1 WHERE nav0_id='$homeID'") or die(mysql_error());
echo "<ul>";
while ($row = mysql_fetch_array($result))
{
// Do not list the home page twice
$pageID2 = $row['nav1_id'];
$pageTitle2 = $row['name'];
echo "<li><a href='" . BASE_URL . "/index.php?id=$pageID2'>$pageTitle2</a></li>";
}
echo "</ul>";
}
echo"</li>";
// List the rest of the pages
$result = mysql_query("SELECT nav0_id, name FROM nav_0") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
// Do not list the home page twice
if ($row['nav0_id'] != $homeID) {
$pageID = $row['nav0_id'];
$pageTitle = $row['name'];
echo "<li><a href='" . BASE_URL . "/index.php?id=$pageID'>$pageTitle</a>";
if ($level == 2)
{
$result2 = mysql_query("SELECT nav1_id, name FROM nav_1 WHERE nav0_id='$pageID'") or die(mysql_error());
echo "<ul>";
while ($row2 = mysql_fetch_array($result2))
{
// Do not list the home page twice
$pageID2 = $row2['nav1_id'];
$pageTitle2 = $row2['name'];
echo "<li><a href='" . BASE_URL . "/index.php?id=$pageID2'>$pageTitle2</a></li>";
}
echo "</ul>";
}
echo "</li>";
}
}
echo '</ul>';
}
?>
websourceview
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<ul id="nav1">
<li>tools
<ul>
<li>emcalc</li>
<li>colorpicker</li>
</ul>
</li>
<li>php</li><ul></ul>
<li>css
<ul>
<li>navigation
<ul>
<li>nav1</li>
<li>nav2</li>
</ul>
</li>
<li>albums</li>
</ul>
</li>
</ul>
Gewijzigd op 12/01/2011 13:58:29 door Steven Cuypers
[.code] [./code] tags gebruiken zonder de .
Gerhard lubbers op 12/01/2011 13:44:57:
[.code] [./code] tags gebruiken zonder de .
oki mercikes
maar ik denk dat het opgelost is als je querys uitvoert, om eerst te controleren of je wel resultaten krijgt met bijv. num_rows als je query uitkomst dan leeg is, dan hoeft hij ook geen <ul></lu> te echoën want dat doet hij nu sowieso.
En ik zou oppassen met het kiezen van de naam van je variabelen want je gebruikt nu 2x $result, misschien werkt het hierdoor wel, maar ik gebruik liever overal een andere naam voor.
Gewijzigd op 12/01/2011 14:05:01 door gerhard l
Misschien effe opzoeken?
zoek dan "geneste", niet "genestelde" ?