Código PHP:
<?php
$encuesta = mysql_query("SELECT * FROM encuestas ORDER BY id_enc LIMIT 0,1");
while($datos = mysql_fetch_array($encuesta)) {
$id_enc = $datos['id_enc'];
$pregunta = $datos['pregunta'];
?>
<div style="width: 300px;">
<strong><?=$pregunta?></strong>
<ul style="list-style: none;">
<?php
$tot = 0;
$opts = mysql_query("SELECT * FROM encuestas_opt WHERE id_enc='".$id_enc."'");
while($dat2 = mysql_fetch_array($opts)) {
$id_opt = $dat2['id_opt'];
$opciones = $dat2['opciones'];
$num_votos = $dat2['num_votos'];
$tot = $num_votos+$tot;
$ptos = $num_votos * 100;
$porcentaje = @round($ptos/$tot,0);
?>
<li style="padding-bottom: 5px;"><?=$opciones?> - <?=$num_votos?> votos - <?=$porcentaje?>%
<div style="width: <?=$porcentaje?>%; height: 6px; background: #cc0000;"></div></li>
<?php
}
?>
</ul>
Total: <?=$tot?>
</div>
<?php
}
?>
He puesto de cabeza el script para ver la falla pero no doy con ella ¿Dónde es que estoy fallando?, gracias de antemano por la ayuda.
Saludos.