Código PHP:
   <?php /* Created on: 20/07/2009 */      
require('conexion_bd.php');    
    $tit = $_POST["tit"];
    $tot_preg = $_POST["tot_preg"];     
 
    //Obtenemos la fecha del sistema
    $fecha = date("d-m-Y");
    
    $sql = "INSERT INTO encuestas (titulo, total_preg, fecha) VALUES ('$tit', '$tot_preg', '$fecha') ";
    $sql = mysql_query($sql) or die ("No fue posible agregar la encuesta");    
                         
    $sqla = "SELECT total_preg FROM encuestas WHERE id_titulo=(SELECT max(id_titulo) FROM encuestas)";
    $sqlb = mysql_query($sqla) or die ("No fue posible seleccionar la encuesta");
    $row=mysql_result($sqlb, 0);
    $tot=$row;
    
            
           
?>
<html>
    <head> <title>  </title> </head>
    <body bgcolor="#A6BDD4">
        <br>
        <form action="encuesta3.php" method="post">
                 <table width=35% border="0" align=center cellpadding=0 background="engranes.jpg">
                    <tr> <td colspan="2"> <font color="#0662AD"> <b><div style="text-align: center">Registro de Preguntas</div></b> </font> </td> </tr>
                    <tr> <td colspan="2"> <br> <br></td> </tr> 
                    <?php
                          for($i=1;$i<=$tot;$i++){ 
                        ?>  
                    
                    <tr> 
                        <td align="center" height="4" width="50%"> <font color="#0662AD"> <b>Pregunta<?php echo $i; ?></b> </font> </td> 
                        <td align="left" height="4" width="50%"><input type="text" name="p[]" size="20%"></td>
                    </tr>
                    <tr> 
                        <td align="center" height="4" width="50%"> <font color="#0662AD"> <b>Total de Respuestas <?php echo $i;?>:</b> </font> </td> 
                        <td align="left" height="4" width="50%"><input type="text" name="tot_resp[]" size="3%"></td>
                    </tr>
                    <tr> <td colspan="2"> <br> </td> </tr>
                    <?php } ?>
                    <tr> <td colspan="2"> <br> </td> </tr>
                 <tr>
                    <td align="center" height="4" colspan="2"> <input type="submit" name="Guardar" value="Enviar"> </td>
                    
                </tr>
            
            </table> 
            
 
        </form>
            
    </body>
</html>   pero al hacer esto me duplica los registros y es por ke en el foreach hace las iteraciones necesarias, para que entiendan mejor:
Código PHP:
   <?php /* Created on: 20/07/2009 */
require('conexion_bd.php');    
 
$sqld = "SELECT total_preg FROM encuestas WHERE id_titulo=(SELECT max(id_titulo) FROM encuestas)";
$sqle = mysql_query($sqld) or die ("No fue posible seleccionar la encuesta");
$rowf=mysql_result($sqle, 0);
$totg=$rowf;
 
$sqla = "SELECT max(id_titulo) FROM encuestas";
$sqlb = mysql_query($sqla);
$row=mysql_result($sqlb, 0);
$id=$row;
 
 
foreach($_POST['p'] as $preg)
{
    foreach ($_POST['tot_resp'] as $tot)
    { 
        $sql = "INSERT INTO preguntas(id_titulo, pregunta, total_resp) VALUES ('$id' , '$preg', '$tot')";
        $sql = mysql_query($sql);
    }
}
 
?>     
 



