The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
Building DHTML menu with PHP
Discuss Building DHTML menu with PHP in the JavaScript Development forum on Dev Shed. Building DHTML menu with PHP JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 1st, 2002, 07:58 AM
|
|
Member
|
|
Join Date: Mar 2001
Posts: 29
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Building DHTML menu with PHP
Hi!
I'm trying to build a script that makes it possible to generate a dhtml navigation menu. The plan is to distinguish several levels of hierarchy (using the output of a database), in this case three: category, product, item.
Realising a complete exposition will distract you from further reading, I simply would like to ask for some idea's how to do this.
An example of the appearence of the menu can be found at www.samsung.nl (difference: no images are to be used).
Thanks!
Max
|

January 1st, 2002, 10:17 AM
|
|
Contributing User
|
|
Join Date: Jul 2001
Location: Oslo
Posts: 1,516

Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
If you're able to write the DHTML you're pretty much there. All you need to do is see which entities repeat, what data is variable, and what you need to extract with PHP. Then it's simply a matter of echoing the right data.
__________________
--
Regards
André Nęss
Puritanism: The haunting fear that someone, somewhere may be having fun
|

January 1st, 2002, 02:20 PM
|
|
Member
|
|
Join Date: Mar 2001
Posts: 29
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
I've got not too much experience with DHTML, but the technique, used at www.samsung.nl, is not very difficult. Problem for me is to write a script, that, regardless the number of levels in the menu, can automate the process of making the menu.
Although not al the comments are translated from dutch, here you find the first lines of my script:
PHP Code:
<?
require("connect.php");
// MenuBuilder. Twee versies: IE4+ en anders --> I specify a browsercheck
$browserinfo = explode(";",$HTTP_USER_AGENT);
if((substr($browserinfo[1],1,4) == "MSIE")&&(substr($browserinfo[1],6,3) >= 4))
{
// IE4+ menu
// Variabelen instellen --> coming section is declaring some variables
$bgcolor = "#888888";
$bgcolordir = "#aaaaaa"; //Als er nog resultaten op lager niveau achterzitten
$borderstyle = "solid";
$borderwidth = "1px";
$bordercolor = "#000000";
$bgtextcolor = "#ffff99";
$textcolor = "#000000";
$fontsize = "9px";
$fontfamily = "helvetica, verdana, arial";
$menubreedte = "120px";
// Afhankelijk van het aantal niveaus subpag's instellen (doelgroepen achterwege gelaten => eerst dynamisch deel werkende krijgen)
$subpag = array("$dir_pagina/categorie.php3?ID=","$dir_pagina/product.php3?ID=","$dir_pagina/item.php3?ID="); //hoogste niveau eerst (=> means: highest level first)
// Afhankelijk van het aantal niveaus de tabelnamen specificeren
$sub = array("categorie","product","item"); //hoogste niveau eerst
// Bepaal de koppeling tussen categorieėn. Eerste is altijd leeg. => here the ID's how to relate the levels to each other are specified
$koppeling = array("","CatID","ProductID");
// Bepaal wat te laten zien voor de listing => fieldnames for displaying in the menu are specified
$show = array("CatNaam","ProductNaam","ItemNaam");
// Bepaal de naam van de IDvariabelen
$idvar = array("CatID","ProductID","ItemID");
// Aantal niveaus => count the number of levels
$aantal_niveaus = count($sub);
// Niveaus opbouwen
$datasub = array();
$countsub = array();
for($i=0; $i<$aantal_niveaus; $i++)
{
echo "niveau $i <br>";
echo $show[$i]."<br>";
// resetten
$query_ext = "";
if($i!=0)
{
$query_ext = "WHERE $koppeling[$i] = ??";
}
$datasub[$i] = mysql_query("SELECT * FROM $sub[$i] $query_ext");
$countsub[$i] = mysql_num_rows($datasub[$i]);
for($p=0; $p<$countsub[$i]; $p++)
{
$rij = mysql_fetch_object($datasub[$i]);
echo $rij->$show[$i];
echo $rij->$idvar[$i];"<br>";
//
// Here is where I ended...it's a mess!
// How to do this?
//
}
}
// einde menubuilder
}
else
{
// Alternatief menu
}
I hope you know a better way doing this. I start making level one, but the next levels...they will be the problem.
Thanks.
Max
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|