Novedades Desafíos Papers y H-Zine Proyectos Foro
foros de discusión

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> AYUDA URGENTE!!!, NECESITO AYUDA CON MENU DINAMICO
hellomoto
post Sep 21 2008, 06:27 PM
Post #1


Recién llegado
*


Group: Hackerss Member
Posts: 1
Joined: 21-September 08
Member No.: 5,546



Hola amigos de hackerss, estoy iniciando en esto de php con base de datos y webs dinamicas y quisiera ayuda para crear un menu dinamico desde base de datos, para empezar tengo las tablas creadas una llamada:
menu, campos: id_menu y nombre_menu y otra
submenu, campos: id_submenu y submenu

ARCHIVO DE CONEXION:

<?

mysql_connect ("localhost", "root", "root") or die ('No se conecto con la base de datos');

mysql_select_db ("delta");

?>

y el codigo de mi menu :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<LINK media=screen href="../menu/style.css" type=text/css rel=stylesheet>
<script src="../menu/urchin.js" type=text/javascript></SCRIPT>
<STYLE type=text/css>DIV.menuBar {
FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: "MS Sans Serif", Arial, sans-serif
}
DIV.menuBar A.menuButton {
FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: "MS Sans Serif", Arial, sans-serif
}
DIV.menu {
FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: "MS Sans Serif", Arial, sans-serif
}
DIV.menu A.menuItem {
FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: "MS Sans Serif", Arial, sans-serif
}

DIV.menuBar {
BORDER-RIGHT: #909090 2px solid; PADDING-RIGHT: 2px; BORDER-TOP: #f0f0f0 2px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 4px; BORDER-LEFT: #f0f0f0 2px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #909090 2px solid; BACKGROUND-COLOR: #cccccc; TEXT-ALIGN: left
}

DIV.menuBar A.menuButton {
BORDER-RIGHT: #ffff 1px solid; PADDING-RIGHT: 6px; BORDER-TOP: #ffff 1px solid; PADDING-LEFT: 6px; Z-INDEX: 100; LEFT: 0px; PADDING-BOTTOM: 2px; MARGIN: 1px; BORDER-LEFT: #ffff 1px solid; CURSOR: default; COLOR: #000000; PADDING-TOP: 2px; BORDER-BOTTOM: #cccccc 1px solid; POSITION: relative; TOP: 0px; BACKGROUND-COLOR: #cccccc; TEXT-DECORATION: none
}

DIV.menuBar A.menuButton:hover {
BORDER-LEFT-COLOR: #f0f0f0; BORDER-BOTTOM-COLOR: #909090; COLOR: #000000; BORDER-TOP-COLOR: #f0f0f0; BACKGROUND-COLOR: #cccccc; BORDER-RIGHT-COLOR: #909090
}

DIV.menuBar A.menuButtonActive {
BORDER-LEFT-COLOR: #909090; LEFT: 1px; BORDER-BOTTOM-COLOR: #f0f0f0; COLOR: #ffffff; BORDER-TOP-COLOR: #909090; TOP: 1px; BACKGROUND-COLOR: #a0a0a0; BORDER-RIGHT-COLOR: #f0f0f0;
}

DIV.menuBar A.menuButtonActive:hover {
BORDER-LEFT-COLOR: #909090; LEFT: 1px; BORDER-BOTTOM-COLOR: #f0f0f0; COLOR: #ffffff; BORDER-TOP-COLOR: #909090; TOP: 1px; BACKGROUND-COLOR: #a0a0a0; BORDER-RIGHT-COLOR: #f0f0f0;
}

DIV.menu {
BORDER-RIGHT: #909090 2px solid; PADDING-RIGHT: 1px; BORDER-TOP: #f0f0f0 2px solid; PADDING-LEFT: 0px; Z-INDEX: 101; LEFT: 0px; VISIBILITY: hidden; PADDING-BOTTOM: 1px; BORDER-LEFT: #f0f0f0 2px solid; PADDING-TOP: 0px; BORDER-BOTTOM: #909090 2px solid; POSITION: absolute; TOP: 0px; BACKGROUND-COLOR: #cccccc;
}

DIV.menu A.menuItem {
PADDING-RIGHT: 1em; DISPLAY: block; PADDING-LEFT: 1em; PADDING-BOTTOM: 3px; CURSOR: default; COLOR: #000000; PADDING-TOP: 3px; WHITE-SPACE: nowrap; TEXT-DECORATION: none
}

DIV.menu A.menuItem:hover {
COLOR: #ffffff; BACKGROUND-COLOR: #000080
}

DIV.menu A.menuItemHighlight {
COLOR: #ffffff; BACKGROUND-COLOR: #000080
}

DIV.menu A.menuItem SPAN.menuItemText {

}

DIV.menu A.menuItem SPAN.menuItemArrow {
MARGIN-RIGHT: -0.75em
}

DIV.menu DIV.menuItemSep {
BORDER-TOP: #909090 1px solid; MARGIN: 4px 2px; BORDER-BOTTOM: #f0f0f0 1px solid
}

</STYLE>

<script type=text/javascript>
function Browser() {
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.version = null;

ua = navigator.userAgent;

s = "MSIE";
if ((i = ua.indexOf(s)) >= 0) {
this.isIE = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}

s = "Netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}

s = "Gecko";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = 6.1;
return;
}
}

var browser = new Browser();
var activeButton = null;
if (browser.isIE)
document.onmousedown = pageMousedown;
else
document.addEventListener("mousedown", pageMousedown, true);
function pageMousedown(event) {
var el;
if (activeButton == null)
return;
if (browser.isIE)
el = window.event.srcElement;
else
el = (event.target.tagName ? event.target : event.target.parentNode);
if (el == activeButton)
return;
if (getContainerWith(el, "DIV", "menu") == null) {
resetButton(activeButton);
activeButton = null;
}
}

function buttonClick(event, menuId) {
var button;
if (browser.isIE)
button = window.event.srcElement;
else
button = event.currentTarget;
button.blur();

if (button.menu == null) {
button.menu = document.getElementById(menuId);
menuInit(button.menu);
}

if (activeButton != null)
resetButton(activeButton);
if (button != activeButton) {
depressButton(button);
activeButton = button;
}
else
activeButton = null;
return false;
}

function buttonMouseover(event, menuId) {
var button;
if (browser.isIE)
button = window.event.srcElement;
else
button = event.currentTarget;
if (activeButton != null && activeButton != button)
buttonClick(event, menuId);
}

function depressButton(button) {
var x, y;
button.className += " menuButtonActive";
x = getPageOffsetLeft(button);
y = getPageOffsetTop(button) + button.offsetHeight;


if (browser.isIE) {
x += button.offsetParent.clientLeft;
y += button.offsetParent.clientTop;
}

button.menu.style.left = x + "px";
button.menu.style.top = y + "px";
button.menu.style.visibility = "visible";
}

function resetButton(button) {
removeClassName(button, "menuButtonActive");

if (button.menu != null) {
closeSubMenu(button.menu);
button.menu.style.visibility = "hidden";
}
}

function menuMouseover(event) {
var menu;
if (browser.isIE)
menu = getContainerWith(window.event.srcElement, "DIV", "menu");
else
menu = event.currentTarget;
if (menu.activeItem != null)
closeSubMenu(menu);
}

function menuItemMouseover(event, menuId) {
var item, menu, x, y;
if (browser.isIE)
item = getContainerWith(window.event.srcElement, "A", "menuItem");
else
item = event.currentTarget;
menu = getContainerWith(item, "DIV", "menu");

if (menu.activeItem != null)
closeSubMenu(menu);
menu.activeItem = item;
item.className += " menuItemHighlight";

if (item.subMenu == null) {
item.subMenu = document.getElementById(menuId);
menuInit(item.subMenu);
}

x = getPageOffsetLeft(item) + item.offsetWidth;
y = getPageOffsetTop(item);
var maxX, maxY;
if (browser.isNS) {
maxX = window.scrollX + window.innerWidth;
maxY = window.scrollY + window.innerHeight;
}

if (browser.isIE && browser.version < 6) {
maxX = document.body.scrollLeft + document.body.clientWidth;
maxY = document.body.scrollTop + document.body.clientHeight;
}

if (browser.isIE && browser.version >= 6) {
maxX = document.documentElement.scrollLeft + document.documentElement.clientWidth;
maxY = document.documentElement.scrollTop + document.documentElement.clientHeight;
}

maxX -= item.subMenu.offsetWidth;
maxY -= item.subMenu.offsetHeight;

if (x > maxX)
x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
+ (menu.offsetWidth - item.offsetWidth));
y = Math.max(0, Math.min(y, maxY));

item.subMenu.style.left = x + "px";
item.subMenu.style.top = y + "px";
item.subMenu.style.visibility = "visible";

if (browser.isIE)
window.event.cancelBubble = true;
else
event.stopPropagation();
}

function closeSubMenu(menu) {
if (menu == null || menu.activeItem == null)
return;

if (menu.activeItem.subMenu != null) {
closeSubMenu(menu.activeItem.subMenu);
menu.activeItem.subMenu.style.visibility = "hidden";
menu.activeItem.subMenu = null;
}

removeClassName(menu.activeItem, "menuItemHighlight");
menu.activeItem = null;
}

function menuInit(menu) {
var itemList, spanList
var textEl, arrowEl;
var itemWidth;
var w, dw;
var i, j;

if (browser.isIE) {
menu.style.lineHeight = "2.5ex";
spanList = menu.getElementsByTagName("SPAN");
for (i = 0; i < spanList.length; i++)
if (hasClassName(spanList[i], "menuItemArrow")) {
spanList[i].style.fontFamily = "Webdings";
spanList[i].firstChild.nodeValue = "4";
}
}

itemList = menu.getElementsByTagName("A");
if (itemList.length > 0)
itemWidth = itemList[0].offsetWidth;
else
return;

for (i = 0; i < itemList.length; i++) {
spanList = itemList[i].getElementsByTagName("SPAN")
textEl = null
arrowEl = null;
for (j = 0; j < spanList.length; j++) {
if (hasClassName(spanList[j], "menuItemText"))
textEl = spanList[j];
if (hasClassName(spanList[j], "menuItemArrow"))
arrowEl = spanList[j];

}

if (textEl != null && arrowEl != null)
textEl.style.paddingRight = (itemWidth
- (textEl.offsetWidth + arrowEl.offsetWidth)) + "px";
}

if (browser.isIE) {
w = itemList[0].offsetWidth;
itemList[0].style.width = w + "px";
dw = itemList[0].offsetWidth - w;
w -= dw;
itemList[0].style.width = w + "px";
}
}

function getContainerWith(node, tagName, className) {
while (node != null) {
if (node.tagName != null && node.tagName == tagName &&
hasClassName(node, className))
return node;
node = node.parentNode;
}

return node;
}

function hasClassName(el, name) {
var i, list;
list = el.className.split(" ");
for (i = 0; i < list.length; i++)
if (list[i] == name)
return true;
return false;
}

function removeClassName(el, name) {
var i, curList, newList;
if (el.className == null)
return;
newList = new Array();
curList = el.className.split(" ");
for (i = 0; i < curList.length; i++)
if (curList[i] != name)
newList.push(curList[i]);
el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {
var x;
x = el.offsetLeft;
if (el.offsetParent != null)
x += getPageOffsetLeft(el.offsetParent);
return x;
}



function getPageOffsetTop(el) {
var y;
y = el.offsetTop;
if (el.offsetParent != null)
y += getPageOffsetTop(el.offsetParent);
return y;
}
</SCRIPT>
<META content="MSHTML 6.00.6000.16681" name=GENERATOR></HEAD>
<?

############################################################
############################################################
#########################
#Armo el menu principal
echo '<DIV class=menuBar style="WIDTH: 985">';
echo '<A class=menuButton href="index_home.php" >Inicio</A> ';
echo '<A class=menuButton onmouseover="buttonMouseover(event, \'opcion_1\');" onclick="return buttonClick(event, \'opcion_1\');" href="#" >Inventarios</A> ';
echo '<A class=menuButton onmouseover="buttonMouseover(event, \'opcion_2\');" onclick="return buttonClick(event, \'opcion_2\');" href="#" >Sistema</A> ';
echo '<A class=menuButton onmouseover="buttonMouseover(event, \'opcion_3\');" onclick="return buttonClick(event, \'opcion_3\');" href="#" >Reportes</A> ';
echo '<A class=menuButton onmouseover="buttonMouseover(event, \'opcion_4\');" onclick="return buttonClick(event, \'opcion_4\');" href="#" >Ayuda</A> ';
echo '</DIV>';

#Armo cada uno de los submenus
echo '<DIV class=menu id=\'opcion_1\' onmouseover=menuMouseover(event)>';
#Si despliega un su submenu es la siguiente linea
#echo '<A class=menuItem onmouseover="menuItemMouseover(event, \'opcion_2\');" onclick="return false;" href="#" target="aplicacion"><SPAN class=menuItemText>probando</SPAN><SPAN class=menuItemArrow>▶</SPAN></A>'; (lo quiero dinamico)
echo '<A class=menuItem href="#" >Alta nuevo producto</A>';
echo '<A class=menuItem href="#" >Modificacion</A>';
echo '<A class=menuItem href="#" >Registrar Entradas</A>';
echo '<A class=menuItem href="#" >Registrar Salidas</A>';
echo '</DIV>';

echo '<DIV class=menu id=\'opcion_2\' onmouseover=menuMouseover(event)>';
echo '<A class=menuItem href="#" >Alta Nueva Familia</A>';
echo '<A class=menuItem href="#" >Alta SubFamilia</A>';
echo '<A class=menuItem href="#" >Alta Sub-SubFamilia</A>';
echo '<A class=menuItem href="#" >Alta Nueva Marca</A>';
echo '</DIV>';

echo '<DIV class=menu id=\'opcion_3\' onmouseover=menuMouseover(event)>';
echo '<A class=menuItem href="#" >Todos los productos</A>';
echo '<A class=menuItem href="#" >Por Marca</A>';
echo '<A class=menuItem href="#" >Por SubFamilia</A>';
echo '<A class=menuItem href="#" >Por Sub-SubFamilia</A>';
echo '</DIV>';




?>
</body>
</html>
Go to the top of the page
 
+Quote Post
xOxo
post Oct 2 2008, 08:53 PM
Post #2


Miembro
***


Group: Hackerss Member
Posts: 78
Joined: 16-July 07
From: Mty N.L.
Member No.: 2,747



mejor pega la url de un ejemplo para saber que es lo que necesitas en realidad we!

Saludos


--------------------
Odio a los coder's, sera por eso que me detesto??
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 

- Lo-Fi Version Time is now: 7th January 2009 - 10:28 AM