loops

Loop SQlite3 database continuously, when query found run script for first 3

I have a SQlite database gets populated when ever someone adds a filename and dir to it, then I want the script to read the newest 3 entries (done with the "LIMIT 3") then I want this script to take those 3 entries and start the "script1.sh" for each of them, then once the script1 has finished one of the 3, I want it to look back into th...

Looping and file_get_contents in PHP

Hello, I have written a page that will scan a site and then extract certain code from the source. That part is working successfully, however I want to run this over multiple pages and dump the details into a database. I am stuggling to get the loop working, this is what I currently have (please be gentle this is my first attempt at anyt...

Is there a way to modify foreach loop variable?

The following code gives an error message: #!/usr/bin/perl -w foreach my $var (0, 1, 2){ $var += 2; print "$var\n"; } Modification of a read-only value attempted at test.pl line 4. Is there any way to modify $var? (I'm just asking out of curiosity; I was actually quite surprised to see this error message.) ...

How to store local variables in jQuery click functions?

I'm trying to figure out how to store external variable values in the functions created during jQuery's click() event. Here's a sample of the code I'm working with now. for(var i=0; i<3; i++){ $('#tmpid'+i).click(function(){ var gid = i; alert(gid); }); } <div id="tmpid0">1al</div> <div id="tmpid1">asd</div> <div id="tmpid2">qwe<...

How to write loop in makefile?

I want to execute these commands ./a.out 1 ./a.out 2 ./a.out 3 ./a.out 4 . . .so on How to write this thing as a loop in make file? ...

how to loop over elements in form using getElementsByName?

Hi, I would like to select certain elements in form by their name, so I suppose using getElementsByName(name). Then I would like to add a value to these elements. How do I do this loop? boxesEL = document.getElementsByName(boxesName); for(var x=0;x<=boxesEL.length;x++){ boxesEL[x].value = "some value"; } I'm getting an error box...

Php - Looping For Different CSS

MySQL $selectSize = "SELECT * FROM products"; $querySize = $db->select($selectSize); while ($product = $db->fetcharray($querySize)) { HTML <ul> <li>Product A</li> <li>Product B</li> <li class='right'>Product C</li> <li>Product D</li> <li>Product E</li> <li class='right'>Product F</li> </ul> Question While getting the prod...

How to reuse a UILabel? (Or any object)

This: UILable *myLabel = [[UILabel alloc] init]; UILable *myLabel = [[UILabel alloc] init]; gives me a redefinition error. But this: for(i=0;i<5;i++) { UILable *myLabel = [[UILabel alloc] init]; // some label code here [self.view addSubview:myLabel]; [myLabel release]; } doesn't. So...

C#: Looping through lines of multiline string

What is a good way to loop through each line of a multiline string without using much more memory (for example without splitting it into an array)? ...

For Loop do action every 5 results

can someone tell me the logic (in any language ) including pseudo code. on how to create a for loop an have it fire an action every 5 results it spits out. basically I'm just trying to emulate a table with 5 columns. Thanks! ...

Help me replace a for loop with an "apply" function

...if that is possible My task is to find the longest streak of continuous days a user participated in a game. Instead of writing an sql function, I chose to use the R's rle function, to get the longest streaks and then update my db table with the results. The (attached) dataframe is something like this: day user_id 2008/11/...

wordpress multiple loops problem

i am trying to build up a single.php page. this page is used to show a full single post. i have 3 loops on it. first two are used (each) for geting a random post from a specific category. 1 <?php query_posts(array('orderby' => 'rand', 'category_name' => announcement, 'showposts' => 1)); if (have_posts()) : while (have_posts()) : the_p...

How to end a loop early in C?

I have a basic C program that produces a number and the user has to guess it (yup, you've already called it: homework). I am able to get pretty much all of it so I am kinda proud, but I open to any errors I have made of course I am still learning. My main two questions are How can I end this program early once the user has selected the...

Run script in php for items not modified yet in mysql

I have db with column named "link" Links have redirect urls, which I want to change. I have php script, which would take the link and gives me out put as follows $redo = get_redirect('htp://www.mydomain.com/long/url/here&ID=123'); print_r($rez); this is the output: Array ( [0] => htp://www.otherdomain.com ) how do I loop all i...

Unexpected behaviour with PHP array references

I'm using references to alter an array: foreach($uNewAppointments as &$newAppointment) { foreach($appointments as &$appointment) { if($appointment == $newAppointment){ $appointment['index'] = $counter; } } $newAppointment['index'] = $counter; $newAppointments[$counter] = $newAppointment; $counter++; } If I print the arra...

SASS - define variable in for loop

I was hoping that defining variables in a loop would work in SASS but unfortunately I get errors saying that the variable isn't defined, here is what I tried @for !i from 1 through 9 !foo = #000 @if !i == 1 !bg_color = #009832 @if !i == 2 !bg_color = #195889 ... #bar#{!i} color: #{!foo} ...

How to initialize char array and empty it again and again in a loop before strcpy() in C?

I want to reinitialize d everytime in a loop char d[90]; while(ptr != NULL) { printf("Word: %s\n",ptr); //int k = 0; strcpy(d, ptr); d[sizeof(d)-1] = '\0'; //something more .... .... } ...

Loop thru 100 background-images onClick

a) I have 100 body-background images b) and a single link The background image should change to the next one in the lot every time the link is clicked, going thru the lot one by one (would be nice if the name/number of current image also is displayed). The images are all in a dedicated directory. jQuery is already loaded. Anyone know...

Example of a While Loop that can't be a For Loop

I know a while loop can do anything a for loop can, but can a for loop do anything a while loop can? Please provide an example. ...

Problem with printing inside the loop: for

Hi, I have problem reading/println after the first two FOR loop in this method. This is strange. How can I solve this problem? private int spacing() { int n = numberOfTriangles(); ArrayList<Double> list_Xs1 = new ArrayList<Double>(); ArrayList<Double> list_Ys1 = new ArrayList<Double>(); for(Polygon p:triangles){ double cX =...