while-loops

Javascript Loop & setInterval

This js will take a value, subtract X amount from it, and then count up to that value. I attempted to accomplish this task by doing a simple while loop, but I couldn't get it work. I was wondering if anyone could comment on how or why the while loop method below doesn't work. This is the only way I could get it to work: function _in...

Loop a part of PHP code every 15 seconds

Hi everyone, i'm trying to make a logging function with php for a tool that captures computer information on Windows. Every 15 seconds the a txt file will be produced with information inside. i want to make it run in the background while the user access other pages and not be interrupted. Here's the code i'm now using <?php $tr...

Updating every row in a table with IF Statement conditions

Hi everyone, this one has me stuck fast. Data: Month Total Impact Forecast ------------------------------------------------ 2010-04-01 45792.0000 1.0000 NULL 2010-05-01 51789.0000 1.0000 NULL 2010-06-01 58228.0000 1.0000 NULL 2010-07-01 52956.5217 1.0000 NULL 2010-08-01 53600....

if statement inside while loop. Why is it doing this?

I am using this: //if in landscape mode while(window.orientation == 90 || window.orientation == -90) { if(!$('#page' + hiddenNextPage).hasClass('showUp')) { $('#page' + hiddenNextPage).addClass('showUp'); $('#page' + hiddenNextPage).css('margin-left', '300px'); ...

javascript, while loop

i'm trying to get my script to wait for user input (click of a button) before continuing, this is v feasible in other languages, but seems impossible in js. basically, i want the user to select an option within a given time frame, if the user selects the wrong option, they're told..script then conts...otherwise, if after a certain amount...

jquery, wait for user input

am basically looking for a way in jquery where my script will wait 15seconds or so, and display a correct ans if the user hasnt selected an answer already. at the moment it just seems to run straight through. ps this method is called in a for loop, with other methods/functions so it runs straight through iterating through the array. thr ...

Dynamic Menu System

I am working on a dynamic menu system as the site I'm build has a strict naming convention. For example, if I have a script are named AboutUs.php, then 'About Us' will be a Parent Menu Item. However if I have a script named Product.Product1.php then 'Product' is the Parent Item with 'Product1' as the Sub Menu Item. The idea is to loop ...

Python - very confused about method and while loop.

I have this method: def is_active(self): if self.is_current_node(): return True cur_children = self.get_children() while cur_children is not None: for child in cur_children: if child.is_current_node(): return True raise Exception(child.display_name) cur_children...

How to add Or to a While Loop in VB?

Currently, lets say that I have this code: While r <> "HI" r = RandomStringGenerator(1) time = time + 1 Console.WriteLine(r) End While how can I make it so that i can say basically this: While r <> "HI" Or While r <> "BY" r = RandomStringGenerator(1) time = time + 1 Console...

Shell script to rename files

I wrote a small shell script based on an example I found here: https://bbs.archlinux.org/viewtopic.php?id=36305 it takes this: bash-3.2$ ls test 001 test 002 test 003 test 004 and turns it into: bash-3.2$ ls 001 002 003 004 rename.sh However it gives me this error (even though it works): bash-3.2$ ./rename.sh mv: missing d...

How to store MySql values as Multidimensional Array using PHP

Hi, I have a database table as follows. <table border='1'><th>Id</th><th>FirstName</th><th>last Name</th><tr><td>1</td><td>Tom</td><td>T</td></tr><tr><td>2</td><td>Jerry</td><td>J</td></tr></table> I would like to store all values as a multi dimensional array using php(using a while loop to retrieve fields).That is, I would like the d...

What loop is faster, while or for

You can get the same output with for and while loops: WHILE $i = 0; while ($i <= 10){ print $i."\n"; $i++; }; FOR for ($i = 0; $i <= 10; $i++){ print $i."\n"; } But which one is faster? ...

setTimeout in loop to check for a change in bounds

This is my code: var b; while(!b){ setTimeout(function(){ alert('sss') b=1; }, 500); } and it will not alert 'sss' What can i do? Updated: I want to get bounds on google maps v3: function get_bounds(){ var bounds_; while(!bounds_){ setTimeout(function(){ ...

What are the practical differences between while(true) and for(;;)?

I personally use while(true) for endless loops, but I've seen examples online that use for(;;). Practically speaking, are there any differences between the two, or is it just a stylistic thing? ...

Nested while loop behavior in R

Hello, I am puzzled by why the output is not what I expect it to be in the following nested while loops: i = 1 j = 1 while(i<5){ print("i") print(i) i = i + 1 while(j<5){ print("j") print(j) j = j + 1 } } The output I get is: [1] "i" [1] 1 [1] "j" [1] 1 [1] "j" [1] 2 [1] "j" [1] 3 [1] "j" [1] 4 [1] "i" [1] 2 [1] "i" [1] 3 ...

While loop help

Hey guys... its the newbie again :) I'm putting together a program that will calculate the area of either a triangle or a square and then prompt the user whether they wish to calculate another. I've got the code working to the point that it will calculate the area of either shape, but then doesn't continue with the rest of the code. F...

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 !=...

How do I combine all elements in an array using comma?

Hey I know this question has with out any doubt been asked a whole lot of times. I though can seem to find a solution. So forgive me if it's way to simple. The question is how do access the end of a while loop. E.g. while($countByMonth = mysql_fetch_array($countByMonthSet)) { $c = $countByMonth["COUNT(id)"]; ...

Need to loop over an array/list/whatever and *return to caller* each element -but the loop only runs once, of course...

I'm obviously missing something here, as this sound basic enough but yet... I have a collection of objects . I need to use each one of them as parameter in constructor for a new object and return each new object to the caller method, one by one. But -if I loop over the collection obviously the loop only runs once, and only returns the 1...

drawing a simple triangle with a while loop

Back learning after silly life issues derailed me! I decided to switch my learning material and I'm now working through Accelerated C++. Chapter 2, Exercise 5: Write a set of "*" characters so that they form a square, a rectangle, and a triangle. I tried but just couldn't get the triangle down exactly. A quick google found the followi...