7, October 2008

Dynamic (2 level) navigation list - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Dynamic (2 level) navigation list
« previous next »
Pages: [1] Print

Author Topic: Dynamic (2 level) navigation list  (Read 1550 times)
Atari ST fan
*
Posts: 7
46 credits
Members referred : 0


« on: Jun 18, 2007, 01:18:10 PM »

I'm new to php mysql but found this tutorial http://www.tutorialized.com/tutorial/Dynamic-2-level-navigation-list/21070 Visit through proxy and would ask if there is somewhere I could see what it looks like, please?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6343
38878 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Jun 18, 2007, 01:35:57 PM »

you got my mail Wink (Welcome at webdigity)


Last blog : Upload images for usage in TinyMCE
Atari ST fan
*
Posts: 7
46 credits
Members referred : 0


« Reply #2 on: Jun 18, 2007, 02:02:16 PM »

I'm trying to figure out how to make dynamic menus and have found this http://www.projectseven.com/tutorials/navigation/auto_hide/index.htm Visit through proxy and then use it here on my testsite http://www.tinemuller.dk/wholocations/bookcode/ Visit through proxy. When I figure out how to make this functioning I think I will be using this http://www.projectseven.com/products/menusystems/pmm/index.htm Visit through proxy.
 
Do you have some files for download to the tutorial? I couldn't find them. I downloaded another tutorial http://www.tutorialized.com/view/tutorial/Dynamic-Dropdown-Menu/15808 Visit through proxy which had source code.

If some of you use this tutorial on a site could I then see it in action, please?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6343
38878 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Jun 18, 2007, 02:14:20 PM »

the complete code is used in the tutorial and I send you the link to the live example by mail (http://www.step2.nl/producten.php Visit through proxy).

actually the HTML code from the "Pop Menu Magic" should be the same but has much more (ajax?) code to get this smooth effect.

having a drop down menu is a case for CSS/javascript


Last blog : Upload images for usage in TinyMCE
Atari ST fan
*
Posts: 7
46 credits
Members referred : 0


« Reply #4 on: Jun 18, 2007, 02:31:25 PM »

I saw your site http://www.step2.nl/producten.php Visit through proxy thanks but you don't use it dynamic, right?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6343
38878 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Jun 18, 2007, 05:29:01 PM »

I saw your site http://www.step2.nl/producten.php Visit through proxy thanks but you don't use it dynamic, right?

you mean this JS effect?


Last blog : Upload images for usage in TinyMCE
Atari ST fan
*
Posts: 7
46 credits
Members referred : 0


« Reply #6 on: Jun 18, 2007, 05:55:06 PM »

Sorry for don't understand this tutorial but I have tried reading the tutorial http://www.tutorialized.com/tutorial/Dynamic-2-level-navigation-list/21070 Visit through proxy and made the table as told to but can't figure out how to use it. There must be missing some text or code I think for this to work?

There is NOT mentioned a database only a table and where to put all the code and what should this file be called? I just copied all the code and pasted it in a index.php file but then what to do?

Have you made this tutorial Olaf?

Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #7 on: Jun 18, 2007, 09:39:40 PM »

The tutorial mentions it is 'powered by PHP and MySQL' MySQL = database, and the table would be the database table that is used to store the menu items in.

the
Code:
CREATE TABLE `dyn_menu` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `label` VARCHAR(50) NOT NULL DEFAULT '',
  `link_url` VARCHAR(100) NOT NULL DEFAULT '#',
  `parent_id` INT(11) NOT NULL DEFAULT '0',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;
part is the MySQL command to create the database table.
« Last Edit: Jun 18, 2007, 09:41:32 PM by Mind_nl »


Last blog : Are You Stumbling Yet?
Atari ST fan
*
Posts: 7
46 credits
Members referred : 0


« Reply #8 on: Jun 19, 2007, 12:20:43 PM »

Am I the only person who doesn't understand this tutorial? Please tell me a little more about how to use this, please?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6343
38878 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Jun 19, 2007, 02:32:14 PM »

Am I the only person who doesn't understand this tutorial? Please tell me a little more about how to use this, please?

maybe you need some basic php skills?

start with setting up the database (use phpmyadmin) and come back if you have this done (don't forget to enter some records)


Last blog : Upload images for usage in TinyMCE
Atari ST fan
*
Posts: 7
46 credits
Members referred : 0


« Reply #10 on: Jun 19, 2007, 03:52:27 PM »

I have got some help from a danish forum and my testsite can now be seen here http://www.tinemuller.dk/2level_tutorial/ Visit through proxy but he say that I need a connections to mysql but as being a beginner and not told in the tutorial it's not so easy, sorry.:-(

It could also be told a little more clear how and what to write in the database for it to work.

I think you should write this two things in the tutorial so other beginners don't have to waste so much time as I had.

Now I have to figure out how to make the connection?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6343
38878 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Jun 19, 2007, 04:10:13 PM »

I have got some help from a danish forum and my testsite can now be seen here http://www.tinemuller.dk/2level_tutorial/ Visit through proxy but he say that I need a connections to mysql but as being a beginner and not told in the tutorial it's not so easy, sorry.:-(

It could also be told a little more clear how and what to write in the database for it to work.

I think you should write this two things in the tutorial so other beginners don't have to waste so much time as I had.

Now I have to figure out how to make the connection?

do you checked the PHP manual? (never said that this tutorial is for beginners Smiley)

or try to search the net for some php/mysql beginner tutorial


Last blog : Upload images for usage in TinyMCE
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #12 on: Jun 19, 2007, 04:18:37 PM »

After setting up your database and creating your table you should know how to connect to it, this is very basic stuff and not part of many tutorials. Here's one way of connecting:

Code:
<?php
// database connection details
$db_host "localhost"; // hostname of your MySQL server. You most likely don't have to change this
$db_name "yourDBname"; // database name
$db_user "yourDBusername"; // database user
$db_pass "yourDBpassword"; // database password

// Lets open up a connection to the database
$db mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");




Last blog : Are You Stumbling Yet?
Atari ST fan
*
Posts: 7
46 credits
Members referred : 0


« Reply #13 on: Jun 19, 2007, 05:42:20 PM »

Now it connect http://www.tinemuller.dk/2level_tutorial/index.php Visit through proxy.

This is was I got now with the help from the danish forum. Can you help me with some informations what to put in the database?

-- Struktur-dump for tabellen `dyn_menu`
--

CREATE TABLE `dyn_menu` (
  `id` int(11) NOT NULL auto_increment,
  `label` varchar(50) collate latin1_general_ci NOT NULL default '',
  `link_url` varchar(100) collate latin1_general_ci NOT NULL default '#',
  `parent_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ;

--
-- Data dump for tabellen `dyn_menu`
--

INSERT INTO `dyn_menu` (`id`, `label`, `link_url`, `parent_id`) VALUES
(1, 'Forside', 'index.php', 0);


Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1807
9006 credits
Members referred : 6



« Reply #14 on: Jun 19, 2007, 06:07:14 PM »

INSERT INTO `dyn_menu` (`id`, `label`, `link_url`, `parent_id`) VALUES
(2, 'subitem', 'index.php', 1);

will insert a sub-menu-item

INSERT INTO `dyn_menu` (`id`, `label`, `link_url`, `parent_id`) VALUES
(3, 'second', 'index.php', 0);

will create a second main item

you will have to replace the index.php in both records of course to point to the correct pages (which will also have to include the menu)


Last blog : Are You Stumbling Yet?
Google dot what?
*
Posts: 2
12 credits
Members referred : 0


« Reply #15 on: Nov 27, 2007, 01:20:03 AM »

I try to use the same script and keep hanging on this browser error:

Code:
Warning: Invalid argument supplied for foreach() in /home/eendit/domains/2cv-onderdelen.nl/public_html/includes/testmenu.php on line 24

that part of the script is here:
Code:
include "../connect.php";
include "../config.php";
include "functies.php";



// nieuw menu begin
$sql = "SELECT id, label, link_url, parent_id FROM dyn_menu ORDER BY parent_id, id ASC";
$items = mysql_query($sql);
while ($obj = mysql_fetch_object($items)) {
    if ($obj->parent_id == 0) {
        $parent_menu[$obj->id]['label'] = $obj->label;
        $parent_menu[$obj->id]['link'] = $obj->link_url;
    } else {
        $sub_menu[$obj->id]['parent'] = $obj->parent_id;
        $sub_menu[$obj->id]['label'] = $obj->label;
        $sub_menu[$obj->id]['link'] = $obj->link_url;
        $parent_menu[$obj->parent_id]['count']++;
    }
}
mysql_free_result($items);

// here starts line number 23
foreach ($parent_array as $pkey => $pval)
{
    if (!empty($pval['count'])) {
        $menu .= "  <li><a class=\"".$extra_style."\" href=\"".$pval['link']."?".$qs_val."=".$pkey."\">".$pval['label']."</a></li>\n";
    } else {
        $menu .= "  <li><a href=\"".$pval['link']."\">".$pval['label']."</a></li>\n";
    }
}

    if (!empty($_REQUEST[$qs_val])) {
    $menu .= "<ul id=\"".$sub_id."\">\n";
    foreach ($sub_array as $sval) {
        if ($pkey == $_REQUEST[$qs_val] && $pkey == $sval['parent']) {
            $menu .= "<li><a href=\"".rebuild_link($sval['link'], $qs_val, $sval['parent'])."\">".$sval['label']."</a></li>\n";
        }
    }
    $menu .= "</ul>\n";
    }

echo dyn_menu($parent_menu, $sub_menu, "menu", "nav", "subnav");

Can someone please tell what I can do to resolve this error?
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6343
38878 credits
Members referred : 374


It's time to use PHP5!


« Reply #16 on: Nov 27, 2007, 08:14:23 AM »

check if your sql is valid, next check if both arrays have values


Last blog : Upload images for usage in TinyMCE
Google dot what?
*
Posts: 2
12 credits
Members referred : 0


« Reply #17 on: Nov 27, 2007, 01:20:04 PM »

Thanks Olaf, problem is fixed
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6818
Tags : php mysql tutorial Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Miscellaneous scripts or snippets (Moderator: Olaf)
Topic: Dynamic (2 level) navigation list
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Oct 07, 2008, 02:46:55 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!





Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.