<form> <?php if ($documentos == "si") { for ($i = 1; $i <= cantidocu; $i++) { echo " Fecha: <input name='fecha$i' type='text' /><br> Importe: <input name='importe$i' type='text' /> "; } } ?> </form>