<?php

//Archivo de configuración
include('config/config.inc.php');


//Metemos la cabecera
include('config/header.inc.php');

?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr> 
      	<td bgcolor="#990000" class="text2" align="center">
	<font color="#FFFFFF"><b>Temas del FAQ</b></font>
	</td>
	</tr>
	
	<tr>
	<td class="text" bgcolor="#cccccc">
      	<?php
$link = mysql_connect($host,$user,$passwd);
mysql_selectdb($db, $link);
      
$sqlquery = "SELECT * FROM $tb_temas ORDER BY ID";
$reltemas = mysql_query($sqlquery);
$numtottemas = mysql_num_rows($reltemas);

while ($row = mysql_fetch_array($reltemas)) {	
	$numtema = $row[0];
	$tema = $row[1];
         ?>
      <a href="#<? echo "tema".$numtema; ?>"><font size="2"><b><?php echo $numtema." ".$tema; ?></b></a></font><br>
      <?php
	}
mysql_free_result($reltemas);
mysql_close();
?>
	</td>
	</tr>
</table>
<table border="0">
	<tr> 
      	<td height="25"></td>
	</tr>
</table>


<?php
    for ($num = 1; $num <= $numtottemas; $num++) {
      $link = mysql_connect($host,$user,$passwd);
      mysql_selectdb($db, $link);
      $sqlquery = "SELECT * FROM $tb_temas WHERE ID = '".$num."'";
      $eltema = mysql_query($sqlquery);
      $rowen = mysql_fetch_array($eltema);
      ?>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr> 
      	<td bgcolor="#990000" class="text2" align="center">
	<font color="#FFFFFF"><b><a name="<? echo "tema".$num; ?>">Tema: <?php echo $rowen[Nombre_tema]; ?></b></font>
	</td>
      </tr>
      <tr>
      	<td class="text" bgcolor="#cccccc">
      <?php
      mysql_free_result($eltema);

      $sqlquery = "SELECT * FROM $tb_faq WHERE tema = '".$num."'";
      $res = mysql_query($sqlquery);
      $numpreg = 0;
      while ($rowpreg = mysql_fetch_array($res)) {	
         $pregunta = $rowpreg[2];
         $ident = $rowpreg[0];
         $numpreg++;
         ?>
<a href="#<? echo $ident; ?>"><b><?php echo $numpreg; ?>.-<?php echo $pregunta; ?></a></b><br>
	<?php
  	}

      mysql_data_seek($res,0);
?>
</td>
</tr>
</table>
<table border="0">
	<tr> 
      	<td height="5"></td>
	</tr>
</table>
<?php

      $numpreg = 0;
	 while ($rowpreg = mysql_fetch_array($res)) {	
         $ident = $rowpreg[0];
         $pregunta = $rowpreg[2];
         $respuesta = $rowpreg[3];
         $numpreg++;
        ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr> 
      	<td bgcolor="#CCCCCC" class="text2" align="left">
	<font color="#990000"><a name="<? echo $ident; ?>"><?php echo $numpreg; ?>.- <?php echo $pregunta; ?></font>
	</td>
      	</tr>
      	<tr> 
      	<td bgcolor="#ffffff" class="text2" align="left">
	<font color="#000000"><?php echo $respuesta; ?></font>
	</td>
      	</tr>
</table>
<table border="0">
	<tr> 
      	<td height="5"></td>
	</tr>
</table>
        <?php
}
?>
<table border="0">
	<tr> 
      	<td height="10"></td>
	</tr>
</table>

<?php

    }
    mysql_free_result($res);
    mysql_close();

//Metemos el pie
include('config/footer.inc.php');
?>