-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
- 0 replies
- 7 views
-
- 3 answers
- 3,247 views
-
QNAP issues patch for an RCE security vulnerability affecting PHP in NAS Drive management
By Alap Naik Desai,
- remote code execution
- rce
- (and 12 more)
- 0 replies
- 6 views
-
Get this Dynamic 2022 Data & IT Security Training Bundle at 97% off
By News Staff,
- neowin deals
- cyber security
- (and 4 more)
- 0 replies
- 6 views
-
- 8 replies
- 1,944 views
-
Question
'Ricardo
Hello everybody,
I having some trouble making my theory working out the way I want it to work out. I have this script that generates a menu from the database, here is the database table:
I have the following code generating the menu:
<?php
class Menu {
public static function render($menu) {
$db = new MySQL;
$db->query("SELECT name, link ".
"FROM menus ".
"WHERE menu = '%s'".
"ORDER BY weight ASC",
$menu);
$result = $db->result();
$output = '<ul>';
foreach ($result as $row) {
$link = Url::get($row['link']);
$output .= '<li><a href="'.$link.'">'.$row['name'].'</a></li>';
}
$output .= '</ul>';
return $output;
}
}[/CODE]
Now I wanted to accomplish the follow menu:
<ul>
<li><a href="test.php">Test</a></li>
<li><a href="about.php">About</a>
<ul>
<li><a href="test2.php">Test 2</a></li>
<li><a href="test3.php">Test 3</a></li>
</ul>
<li><a href="credits.php">Credits</a>
</ul>
[/CODE]
As you can see I want to accomplish a sub menu. Do I need to add a extra row so that (for example) test2.php has the weight 2.1 so it will be a <ul> under the about.php <li>?
I really could use some help. Thank you.
Link to comment
Share on other sites
4 answers to this question
Recommended Posts