$num_rows = mysql_num_rows ($result); $steps = 0; $step_row = 100; ob_start (); while ( $row = mysql_fetch_assoc ( $result ) ) { if ( $steps > $step_rows ) { echo "Processed $steps result(s)
"; ob_flush(); flush(); $steps = 0; } /* we first copy the file into the folder */ $cp_command = 'cp ' . row['somedata'] . ' ' . $temp_dir_name; $text = shell_exec ( $cp_command ); $steps = $steps + 1; } mysql_free_result ( $result ); echo "Processed $num_rows result(s) completely
"; ob_end_flush ();