Ver Mensaje Individual
  #2 (permalink)  
Antiguo 14/07/2006, 14:13
eli912
 
Fecha de Ingreso: febrero-2006
Mensajes: 30
Antigüedad: 18 años, 2 meses
Puntos: 0
PHP y MENUS

Realize un menu parecido a este link: http://platea.pntic.mec.es/~jmas/man...horizontal.htm

Pero deseo que jale los datos desde el msql:

mi codigo php:
Código PHP:
<? include "conecta.php";    
    
$sql="select * from  categoria";
    
$rs=mysql_query($sql);
    
$nreg=mysql_num_rows($rs);    
    
$sql2="SELECT cod_prod, nom_prod FROM  producto, categoria where categoria.cod_cat =producto.cod_cat" ;
    
$rs2=mysql_query($sql2);
    
$nreg2=mysql_num_rows($rs2);
 
?>
<html>
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="drop_down.js"></script>
<style type="text/css">
@import "style3.css";
</style>
</head>
<body>
<ul id="nav">
    <? for($i=0;$i<$nreg;$i++){ ?>
    
    <li><a href="#" value="<?echo mysql_result($rs,$i,'cod_cat')?>">
               <?echo mysql_result($rs,$i,'nom_cat');?></a>    <?}?>
                   
    <ul><?for($i=0;$i<$nreg2;$i++){?>                        
       <li><a href="#" value="<?echo mysql_result($rs2,$i,'cod_prod')?>">
              <?echo mysql_result($rs2,$i,'nom_prod');?></a>  </li><?}?>         
    </ul>
    
   </li>   
<ul>
y los dos campos de la Base de Datos:

# Estructura de tabla para tabla `categoria`
#

CREATE TABLE categoria (
cod_cat int(11) NOT NULL default '0',
nom_cat varchar(30) NOT NULL default ''
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Estructura de tabla para tabla `producto`
#

CREATE TABLE producto (
cod_prod int(11) NOT NULL default '0',
cod_cat int(11) NOT NULL default '0',
nom_prod varchar(30) NOT NULL default '',
PRIMARY KEY (cod_prod)
) TYPE=MyISAM;
# ---------------------