loops

PHP While Loop Help

Here is my while loop. Any suggestions? <?php error_reporting(E_ALL); ini_set("display_errors", "on"); include('header.php'); $search = "current_page_item"; include('nav.php'); include('sidebar.php'); ?> <div class="primary"> <br/> <?php $userId = $_GET['id']; echo "<div class=\"item_list\">"; $sql = "SELECT * FROM user ...

how can i get the value of array

Hi, i want to get all the values on "ListNumber", how can i loop it using php? thanks in advance :) [ListNumbersList] => SimpleXMLElement Object ( [Record] => SimpleXMLElement Object ( [Returned] => 1 ) [ListNumber] => Array ( [0] => 1 ...

finding loops in graph/tree

Possible Duplicate: Best algorithm for detecting cycles in a directed graph Hi Could sb tell which algoritym I should use to find a loop/cycle in graph or tree ? Maybe sb has a pseudocode or sth I could start with. ...

WordPress posts sorted by category and year

I've been on a long google search trying to find the solution to this... I am creating a cv manager theme using a WordPress install to control content. I have managed to organise all WP posts in categories but would also like to list those posts in year groupings. Currently I have this: <?php // Categories $cvm_cat_args = array...

change array of images using loop objective-c

Hello everyone, I have a NSMutablArray of UIButtons. I want to index through them and set their images based on other data. The problem I'm having is finding a loop to pass them all through (I don't want a long list of ifs). for (UIButton *theButton in theButtons) { A loop will not work. What other way is there to be able to set i...

In a PHP (Wordpress) loop how do you generate a sequence of unique numbers?

If I have a list being generated in a loop, something like: <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div id="slide"> <ul> <li class="slide-<?php //how can I generate an integer here ?>"> <a href="#">stuff</a></li> </ul> </div> How could I append a sequential number to each of those classes, and/or those hrefs...

Loop through NSArray Setting objectAtIndex Value

Hi I have a bunch of NSStrings in a NSMutableArray. I have added them to the array and now I want to loop through the array, getting each object in it (the strings) and set them to a common value @"No Lessons". This is how I have the loop so far: But how can I get the object then set it? Currently its fairly simple, just getting loopin...

python: does `for i in obj.func()` re-run `func` every iteration?

let's say I have the following code: for a in object.a_really_huge_function(): print a In order to prevent a_really_huge_function from running multiple times, I am used to doing this in other languages: a_list = object.a_really_huge_function() for a in a_list: print a Is that necessary in Python? Will the part after in run ...

How can I continue with a loop when an error occurs in MATLAB?

I'm converting some .dat files into .mat files using a function. I'm calling this function inside a loop to convert a number of files. There are some cases where my .dat file is corrupted and the function cannot convert and an error occurs, stopping the loop. Now my question is: Is there any command wherein when the error occurs it shou...

Infinite Thread that may or may not run a CDialog each loop

I am working on a MFC project where I need a separate loop that will run continually or once every few seconds, and each time it may or may not need to run a Dialog to get some input from the user. I was thinking of using AfxBeginThread, but from what I have read about it, it doesn't really work with a continuous loop. ...

Python - Way to restart a for loop, similar to "continue" for while loops?

Basically, I need a way to return control to the beginning of a for loop and actually restart the entire iteration process after taking an action if a certain condition is met. What I'm trying to do is this: for index, item in enumerate(list2): if item == '||' and list2[index-1] == '||': del list2[index] *<some ...

Adding up the sum of random generated numbers in a for loop

class Class1 { [STAThread] static void Main(string[] args) { int lap, avg = 0; double time = 0; Random generator = new Random(); time = generator.Next(5, 10); for (lap = 1; lap <= 10; lap++) { time = (generator.NextDouble())* 10 + 1; Console.WriteLine("Lap {0} with a lap time of {1} seconds!!!!"la...

MIPS programming issue

Hello all. I'm having a MIPS issue here. What I'm trying to do is have the user input any number and have the program spell out the name of each digit in the number. So for example, the user inputs 495 and the machine would spell out "Four Nine Five". I'm trying to push each digit of the number onto the stack, then pop each one off. ...

How do I break an outer loop from an inner one in Perl?

Suppose I have a piece of Perl code like: foreach my $x (@x) { foreach my $y (@z) { foreach my $z (@z) { if (something()) { // I want to break free! } // do stuff } // do stuff } // do stuff } If something() is true, I would like to break ('last') all the loops. how can I do that? I thought of two options, bot...

Assigning and removing objects in a loop: eval(parse(paste(...

I am looking to assign objects in a loop. I've read that some form of eval(parse( is what I need to perform this, but I'm running into errors listing invalid text or no such file or directory. Below is sample code of generally what I'm attempting to do: x <- array(seq(1,18,by=1),dim=c(3,2,3)) for (i in 1:length(x[1,1,])) { eval(parse(...

Error when using while loop

The while loop isnt working. i get an error when it hits the break to get out of the loop. the error is no loop statement to break out of. static void Main(string[] args) { accounts myclass = new accounts(); string userin; myclass.fillAccounts(); //int i = 0; //while (i != 1) do { } while (userin !=...

Simplify looping through an array which could be flat or multidimensional

Often, I will have an array holding a set of values each of which I need to process. Sometimes, the array will only hold a single set, in which case each value needs to be put through the process. Other times, the array will hold many sets, in which case each value will be an array and each value of those arrays will need to be processed...

F# Creating a single loop with multiple functions

I'm just starting to dig into some programming and decided to go with F#. As practice, I was trying to convert a script I made in .bat into F#. I'm having trouble creating a looping function that does more than one thing. Here is the code from the old script for this loop. :Select cls echo. echo Which Game? echo. echo 1. Assassin's C...

Add content to specific columns in table using jQuery

I have a table structure looking something like this. One outer table and in almost each td I got an inner table. <table class="outertable"> <tr> <td> <table class="innertable"> <tr><td></td></tr> <tr><td></td></tr> </table> </td> <td> <t...

iPhone background task stops running at some point

Hi, In my iPhone app I have a background task that starts running when the app enters the background state. The task runs fine and is structured in a loop like this: run. sleep for 5 min. run. sleep for 5 min. etc. For some reason, the task stops running after a certain amount of time... say half an hour to an hour. Can anyone help ...