loops

Grouping results under a heading

This is probably really obvious and simple - but it isn't to me with my rudimentary knowledge:) I've got two tables: table_items ----------- item_id ¦ item_name ¦ item_describtion ¦ more item stuff..... table_subitems ----------------- subitem_id ¦ item_id ¦ subitem_name ¦ More subitem stuff Each item can have zero to pretty much un...

in plsql, i saw some one use for loop without define the loop index, why? how?

hi everyone, in plsql, i saw some one use for loop without define the loop index, and the database can execute correctly. but i can't find the description of this syntax in oracle documentation. can anyone explain it? great thanks! the following code is an example, notice the *inner_c* is not defined: declare v_current_nr NUMBER; b...

Div Tables with ASP.NET MVC

I'm trying to find a better way to use a div table with ASP.NET MVC, the problem I see is that you need to do loads of looping, rather than one loop if I had to use a traditional <table> table. Example <div class="column"> <div class="row">Name</div> <% foreach (Person person in (List<Person>)ViewData.Model) {%> <div clas...

c# loop fails when adding object to list!

hey, this i have a loop that adds gathered strings and ints into an object, and then adds that object into a list. I need it to check if there is already an object with a property == to the one i'm about to assign, and then depending on which the property is, I either want to change one of its properties, or still add a new object. I'll ...

Loop design for first/last items and item groups?

I'm often confronted with the following situation: I have some data in a table (nested arrays) and need to loop over all items in it. Requirements: The first item should be identified and handled separately. The last item should be identified and handled separately. If similiar items are sorted they should be identified in groups with...

switch statement and loops using jquery/javascript

Is there a way I can generate switch statements in jquery/javascript by using some sort of loop to do the work for me? For example, if I had a statement like: switch ($("#play option:selected").text()) { case '1': $("#play_1").slideDown().find("input").addClass("someClass"); break; case '2': $("#play_1"...

Delete SQL looping

I want to keep only 1000 entries for each clientid. The code below does what I want but does not loop through the clientid, instead keeping 1000 total of any of the clients. Is there a way to do this in sql? I was told i need a cursor, but I am hoping not. SQL 2005 DECLARE @ids TABLE ( id int ) DECLARE @clients TABLE ( clientid varc...

jquery ajax problem

A few days ago I posted this question: http://stackoverflow.com/questions/1169387/switch-statement-and-loops-using-jquery-javascript which ended up with me creating a series of divs using this code for (var i = 1; i <= $("#play option:selected").text(); ++i) { $("#play_"+i).slideDown().find("input").addClass("someClass"); } ...

php array and foreach?

Below is my code I am trying to get to work but I really have very little knowledge of array and foreach. So it doesn;t work correctly I need to show a dropdown select form to the browser with the contents of the array I also need to have the item selected if it is == to $mycountry Lastly I would like to show the USA and UK at the top ...

One after an other...

I'm having trouble making something happen over and over without a for loop. Take a look at this: package { import flash.display.Sprite; import flash.events.Event; public class Main extends Sprite { public function Main() { addEventListener("done", caller); caller(); ...

Python loop counter in a for loop

In my example code below, is the counter = 0 really required, or is there a better, more Python, way to get access to a loop counter? I saw a few PEPs related to loop counters, but they were either deferred or rejected (PEP 212 and PEP 281). This is a simplified example of my problem. In my real application this is done with graphics an...

NAnt foreach loop folders recursive

Hi, Does anybody know how I could create a recursive loop with NAnt? I need to loop through all of my folders and upload the files to our webserver. I am using this NAnt ftp task (http://www.spinthemoose.com/~ftptask), however it doesn't seem to upload the entire directory. It uploads only the mentioned files in my put element. Thanks...

SQL Server 2005 recursive query with loops in data - is it possible?

I've got a standard boss/subordinate employee table. I need to select a boss (specified by ID) and all his subordinates (and their subrodinates, etc). Unfortunately the real world data has some loops in it (for example, both company owners have each other set as their boss). The simple recursive query with a CTE chokes on this (maximum r...

C# Container Question

Hi, I'm having a weird problem with adding stuff to my Container. Whenever I try to add the items it simply exits the while loop, even though isServer is still 1. I've tried to make a custom function, same result. Then i tried calling the Add(..) function directly and still same result. I don't see how inserting items to my container is...

Can this code to loop through photos in a folder be optimised?

I have written this code having not used PHP for 2 years now to loop through a folder of photos and write them to the page in alphabetical order. It is a fairly simple request but it took me the best part of 15 minutes to write. if ($handle = opendir('photos')) { $count = 0; $list[] = array(); while (false !== ($file = readdir($ha...

Calling remove in foreach loop in Java

In Java, is it legal to call remove on a collection when iterating through the collection using a foreach loop? For instance: List<String> names = .... for (String name : names) { // Do something names.remove(name). } As an addendum, is it legal to remove items that have not been iterated over yet? For instance, //Assume that...

Force an iteration of a loop

In my "native" programming language (RPG), I can write a loop and just leave the loop or force an iteration. It is kind of like a GOTO. dow (x < 999); read file; if (%eof); leave; // Leave the loop endif; if (field <> fileField); iter; // Iterate to the next record endif; enddo; My question is if there is a similar o...

Looping through mysql_fetch_array in PHP

So I have the following: $i = 0; $records = mysql_num_rows($sections_query); $row_sections = mysql_fetch_array($sections_query); foreach ($row_sections as $value) { echo $value . "<br />"; } The value of $records becomes 4 after execution and the DB has 2 columns per row. The first column value is 'section_id' and the second ...

Stumped in the middle of a PHP loop

Here's what I've got so far- $awards_sql_1 = mysql_query('SELECT * FROM categories WHERE section_id = 1') or die(mysql_error()); $awards_sql_2 = mysql_query('SELECT * FROM categories WHERE section_id = 2') or die(mysql_error()); $awards_sql_3 = mysql_query('SELECT * FROM categories WHERE section_id = 3') or die(mysql_error()); $awards_s...

What is the best method to loop through TreeView nodes and retrieve a node based on certain value?

What is the best method to loop through TreeView nodes and retrieve a node based on certain value? ...