Problem with php button

Hi, I have a form with a php button that add regs to another table, but I have a recordset with 24 regs and just two was added.

Thus is the code:

/**
	 * Selecting a field from another table using the recordset
	 */
	
	// Check for record
	$check_sql = 'SELECT Participante_Id'
	      . ' FROM participantes'
	      . " WHERE Curso_Id = " . {Curso_Id} . " and Aprobado = 'S' order by Aprobado desc"; // this sql statement works fine and return 24 records
	sc_select(rs, $check_sql);
	
	//initialize the field
	{field_total} = 0;
	
	if (false == {rs})   // Error while accessing database
	{
	  sc_error_message('Error while accessing database.');
	}
	else
	{
	  while(!$rs->EOF)
	  {
	    {Participante} = $rs->fields[0];
	    
	    /**
		 * Insert a record on another table
		 */
		
		// SQL statement parameters
		$insert_table = 'certificados';       // Table name
		$insert_fields = array(          // Field list, add as many as needed
		           'Cursoid' => "'{Curso_Id}'",
		           'Prestadorid' => "'{Nombre}'",
		           'Participanteid' => "'{Participante}'",
		           'Vencimiento' => "'{due_date}'",
		           'Codigo_Barras' => "'{codbar}'",
		           'Codigo_Barras_2' => "'{codbar}'",
		         );
		
		// Insert record
		$insert_sql = 'INSERT INTO ' . $insert_table
		      . ' ('      . implode(', ', array_keys($insert_fields))  . ')'
		      . ' VALUES ('  . implode(', ', array_values($insert_fields)) . ')';
		sc_exec_sql($insert_sql);

	    
	    {field_total} += $rs->fields[0];
    
 
	    $rs->MoveNext(); 
	  
	  $rs->Close();
	}

the script add just the first two records of 24 and no error was showed. What I am doing badly?