How can I put submenu within a menu from a database

-1

I have the tables in the database well done, but then when I do the code, the content does not even appear, I wanted to have help sff'

The code I have is this:

$resultado = mysql_query("SELECT titulo FROM menu WHERE id_menu = 1 ORDER BY id_menu   ") or die(mysql_error());
while($linha = mysql_fetch_array($resultado)) {
   echo "<li> ".$linha[''] . " " . $home ." </li>";
} 

$resultado = mysql_query("SELECT titulo FROM menu WHERE id_menu = 2 ORDER BY id_menu   ") or die(mysql_error());
$result = mysql_query("SELECT titulo FROM submenu WHERE id_submenu = 2 ORDER BY id_submenu   ") or die(mysql_error());
while($linha = mysql_fetch_array($resultado)) {
   echo " <li class= 'dropdown ' > 
  <a  echo $orgaosMenu;  href='#' class='dropdown-toggle' data-toggle='dropdown' style='padding-top: 15px;border-top: 0px solid #3B7D26;'>" . $linha['titulo'] . "<b class='caret'></b></a>
     " . $orgaosMenu . "</li>";

     while($line = mysql_fetch_array($result)){
      echo "<ul class='dropdown-menu'> 
      <li>   " .$line['titulo'] . "   </li>";
     }
} 

$resultado = mysql_query("SELECT titulo FROM menu WHERE id_menu = 3 ORDER BY id_menu   ") or die(mysql_error());
while($linha = mysql_fetch_array($resultado)) {
   echo " <li class= 'dropdown ' > 
  <a  echo $autarcasMenu;  href='#' class='dropdown-toggle' data-toggle='dropdown' style='padding-top: 15px;border-top: 0px solid #3B7D26;'>" . $linha['titulo'] . "<b class='caret'></b></a>
     " . $autarcasMenu . "</li>";
} 

$resultado = mysql_query("SELECT titulo FROM menu WHERE id_menu = 4 ORDER BY id_menu   ") or die(mysql_error());
while($linha = mysql_fetch_array($resultado)) {
   echo " <li class= 'dropdown ' > 
   <a  echo $militanciaMenu;  href='#' class='dropdown-toggle' data-toggle='dropdown' style='padding-top: 15px;border-top: 0px solid #3B7D26;'>" . $linha['titulo'] . "<b class='caret'></b></a>
     " . $militanciaMenu . "</li>";
}     

$resultado = mysql_query("SELECT titulo FROM menu WHERE id_menu = 5 ORDER BY id_menu   ") or die(mysql_error());
while($linha = mysql_fetch_array($resultado)) {
   echo " <li  > 
  <a  echo $multimediaMenu;  href='#' class='dropdown-toggle' data-toggle='dropdown' style='padding-top: 15px;border-top: 0px solid #3B7D26;'>" . $linha['titulo'] . "<b ></b></a>
     " . $multimediaMenu . "</li>";
}    

$resultado = mysql_query("SELECT titulo FROM menu WHERE id_menu = 6 ORDER BY id_menu   ") or die(mysql_error());
while($linha = mysql_fetch_array($resultado)) {
   echo " <li  > 
  <a  echo $contactosMenu;  href='http://www.w3schools.com/php/php_mysql_where.asp' class='dropdown-toggle' data-toggle='dropdown' style='padding-top: 15px;border-top: 0px solid #3B7D26;'>" . $linha['titulo'] . "<b ></b></a>
     " . $contactosMenu . "</li>";
}
?>
    
asked by anonymous 13.10.2014 / 16:42

1 answer

0

It seems to me that the problem is in mysql_fetch_array () ... Do not associate the column names with the array and therefore you can not access the $ line ['title'] ... Try to use mysql_fetch_assoc ($ result) or mysql_fetch_array ($ result, MYSQL_ASSOC);

    
13.10.2014 / 17:03