You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
58 lines
1.6 KiB
<?php // Generate the menu
|
|
|
|
// menu function definitions
|
|
|
|
function start($menu) {
|
|
header("Content-type: text/html");
|
|
print("<html>\n<head>\n<base target=\"$menu->target\">\n");
|
|
print("<link rel=stylesheet href=\"/styles/$menu->style\" ");
|
|
print("type=text/css>\n</head>\n<body>\n<div class=menu>\n");
|
|
print("<h2 class=title>Navigation Menu<hr></h2>\n");
|
|
return($menu->id);
|
|
}
|
|
|
|
function finish($menu) {
|
|
print("</div>\n</body>\n</html>");
|
|
}
|
|
|
|
function main($label) {
|
|
print("<a class=main href=\"$label->url\"");
|
|
if($label->target) print(" target=\"$label->target\"");
|
|
print(">$label->dat</a><br>\n");
|
|
}
|
|
|
|
function sub($label) {
|
|
print("  <a class=sub href=\"$label->url\"");
|
|
if($label->target) print(" target=\"$label->target\"");
|
|
print(">$label->dat</a><br>\n");
|
|
}
|
|
|
|
// import database configuration and functions
|
|
require("db.php3");
|
|
|
|
// connect to the database
|
|
$connection = connect($host, $dbname);
|
|
if($connection) {
|
|
// setup query value
|
|
$query = "select * from menu where content = \"$content\"";
|
|
$result = query($connection, $query);
|
|
if($result) {
|
|
$menu = fetch_object($result,0);
|
|
$mid = start($menu);
|
|
// query for menu labels
|
|
$query = "select * from label where mid=\"$mid\" order by ord";
|
|
$result = query($connection, $query);
|
|
$count = numrows($result);
|
|
if($count) {
|
|
// dynamically call a function for each record
|
|
// based on the contents of its "type" field
|
|
for($row=0; $row < $count; $row++) {
|
|
$label = fetch_object($result, $row);
|
|
$function = $label->type;
|
|
$function($label);
|
|
}
|
|
finish($menu);
|
|
}
|
|
}
|
|
}
|
|
?>
|