Bom pessoal, a dúvida é a seguinte. o banco de dados contém as informações para o menu, categorias e subcategorias. apos os selects tudo certo. e então preciso 'esconder' parte do menu(as subcategorias). pra não ficar muito grande. coloquei um código em ação mas não tive exito total. funcionou porém só abre uma subcategoria de uma unica categoria. mesmo clicando em outras categorias. o codigo vai abaixo pra ver c alguém consegue ter uma luz. <style type='text/css'>.texthidden {display:inline}.shown {display:block}</style>
<script type='text/javascript'>document.write('<style>.texthidden {display:none} </style>');
</script><script type='text/Javascript'>function expandcollapse (postid) {whichpost = document.getElementById(postid);if (whichpost.className=="shown") {whichpost.className="texthidden";}else {whichpost.className="shown";}}</script>
<?php
//SELECT DAS CATEGORIAS DE IMOVEIS
$i = '0';
$sql1 = "SELECT * FROM categoria ORDER BY nome Asc";
$resultado1 = mysql_query($sql1) or die ("Não foi possível realizar a consulta ao banco de dados".mysql_error());
while ($row1 = mysql_fetch_row($resultado1)){
$sql2 = mysql_query("SELECT * FROM produtos WHERE sub = '$row1[0]'");
$total_c = mysql_num_rows($sql2);
echo "<a href=\"java script:void(0);\" onclick=\"expandcollapse('favoritos')\"><li><strong>$row1[1]</strong></li></a>";
$sqlsub = mysql_query("SELECT * FROM sub_cat where cat = $row1[0]");
while ($rowc = mysql_fetch_row($sqlsub)){
echo "<ul id=\"favoritos\" class=\"texthidden\"><a href=\"$site_d/Produtos/list1.php?categoria=$rowc[0]\">$rowc[2]($total_c)</a></ul>";
}
}
?>
EXEMPLO
<!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>
<style type='text/css'>.texthidden {display:inline}.shown {display:block}</style>
<script type='text/javascript'>document.write('<style>.texthidden {display:none} </style>');
</script><script type='text/Javascript'>function expandcollapse (postid) {whichpost = document.getElementById(postid);if (whichpost.className=="shown") {whichpost.className="texthidden";}else {whichpost.className="shown";}}</script>
<style type='text/css'>
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<a href="java script:void(0);" onclick="expandcollapse('favoritos')">texto</a><br/>
<ul id="favoritos" class="texthidden">
<li><a href="http://endereço.com/" target="_blank">Escreva aqui o nome do blog</a></li>
<li><a href="http://endereço.com/" target="_blank">Escreva aqui o nome do blog</a></li>
<li><a href="http://endereço.com/" target="_blank">Escreva aqui o nome do blog</a></li>
<li><a href="http://endereço.com/" target="_blank">Escreva aqui o nome do blog</a></li>
</ul>
</body>
</html>