Olive Branch MS Chamber of Commerce (circa Oct 1999)
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

58 lines
1.6 KiB

  1. <?php // Generate the menu
  2. // menu function definitions
  3. function start($menu) {
  4. header("Content-type: text/html");
  5. print("<html>\n<head>\n<base target=\"$menu->target\">\n");
  6. print("<link rel=stylesheet href=\"/styles/$menu->style\" ");
  7. print("type=text/css>\n</head>\n<body>\n<div class=menu>\n");
  8. print("<h2 class=title>Navigation Menu<hr></h2>\n");
  9. return($menu->id);
  10. }
  11. function finish($menu) {
  12. print("</div>\n</body>\n</html>");
  13. }
  14. function main($label) {
  15. print("<a class=main href=\"$label->url\"");
  16. if($label->target) print(" target=\"$label->target\"");
  17. print(">$label->dat</a><br>\n");
  18. }
  19. function sub($label) {
  20. print("&nbsp <a class=sub href=\"$label->url\"");
  21. if($label->target) print(" target=\"$label->target\"");
  22. print(">$label->dat</a><br>\n");
  23. }
  24. // import database configuration and functions
  25. require("db.php3");
  26. // connect to the database
  27. $connection = connect($host, $dbname);
  28. if($connection) {
  29. // setup query value
  30. $query = "select * from menu where content = \"$content\"";
  31. $result = query($connection, $query);
  32. if($result) {
  33. $menu = fetch_object($result,0);
  34. $mid = start($menu);
  35. // query for menu labels
  36. $query = "select * from label where mid=\"$mid\" order by ord";
  37. $result = query($connection, $query);
  38. $count = numrows($result);
  39. if($count) {
  40. // dynamically call a function for each record
  41. // based on the contents of its "type" field
  42. for($row=0; $row < $count; $row++) {
  43. $label = fetch_object($result, $row);
  44. $function = $label->type;
  45. $function($label);
  46. }
  47. finish($menu);
  48. }
  49. }
  50. }
  51. ?>