while-loops

for vs foreach vs while which is faster for iterating through arrays in php

which one is the fastest for iterating through arrays in php? or does another exist which is also faster for iterating through arrays? ...

Retrieving and Presenting SQL Joined Table Records with PHP, Sqlite (or MySql), and HTML

Hello: Please bare with me while I try to explain my question. I have a Sqlite database that has a table consisting of company information (Companies) and a table consisting of product information (Products). The Companies table id is Company_Name. It is joined with the Products table by Company_Name. For example, Company "A" can ha...

In TSQL, what is the best way to iterate through 1..* child nodes of XML data and retreive values?

I have a simple XML structure: <Receipt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ReceiptID="0" UserID="0" UserCardID="0" PaymentMethodID="1" MerchantID="0" MerchantTaxID="MERCHANT_TAX_ID" MerchantReceiptID="MERCHANT_RECEIPT_ID" MerchantReceiptReferenceID="MERCHANT_RECEIPT_REF_I...

jQuery while loop not waiting for animation

I have a jQuery function that does a .clone() on an object, and then an .insertAfter() and a .slideDown() on the cloned object. This whole function is wrapped inside a while loop. I will keep this as short and concise as possible and show a generic example: while (statement) { // code for clone and insert ... $("#newly_created_...

How to end the current loop(but not the whole while statement) in PHP?

in While(),How to skip the following nested statements and execute next loop of the while() statement? ...

Does Java recognize infinite loops?

Given the following code sample: public class WeirdStuff { public static int doSomething() { while(true); } public static void main(String[] args) { doSomething(); } } This is a valid Java program, although the method doSomething() should return an int but never does. If you run it, it will end in an infinite loop. If you pu...

break out of a loop that contains a switch statement (C#)

Hello, I am having trouble figuring out how to break out of a loop that contains a switch statement. Break breaks out of the switch, not the loop. There is probably a more elegant solution to this. I have implemented a flag that starts out as true and gets set to false and ends the loop. Can you offer a better solution? Background: ...

The minimum number of times the while loop is executed is?

what is the minimum number of times the while loop is executed? Is it zero? Not talking about DO ...

PHP: Changing the query variables during the while loop

I was hoping to change one of the variables of a query, from inside the while loop, is it possible to do this? EG. $query = mysql_query('SELECT column1, column2 FROM table1 WHERE column1 = "'.$variable.'";', $conn); while ($data = mysql_fetch_assoc($query)) { if($data['column2'] == 'original') { $variable = 'altered'; } ...

How to fix this C# looping and processing code?

Hi, I have a List of Lat/Lon co-ordinates that I'm processing in a while(true) loop. During the loop I'm building a query that will be sent to a remote service for processing. The remote service can only accept 12 pairs of Lat/Lon co-ordinates, however my list may contain several thousand. What I want to do is build the query and the...

PHP script stops running arbitrarily with no errors.

I was working on a fairly long script that seemed to stop running after about 20 minutes. After days of trying to figure out why, I decided to make a very simple script to see how long it would run without any complex code to confuse me. I found that the same thing was happening with this simple infinite loop. At some point between 15 an...

Parallel while Loops in Python

Hi, I'm pretty new to Python, and programming in general and I'm creating a virtual pet style game for my little sister. Is it possible to run 2 while loops parallel to each other in python? eg: while 1: input_event_1 = gui.buttonbox( msg = 'Hello, what would you like to do with your Potato Head?', title = 'Main Scr...

Unable to break out of "while" loop - C

I'm trying to implement a simple while loop to let the user enter multiple marks without having to reload the application, for some reason no matter what i seem to enter it always loops. I've looked using the debugger and it doesn't seem to accept the final scanf() asking whether to repeat itself or not. int mark = 0; char grade; ...

Printing a Pattern with While loops and only using three output statements in C

Hello Everyone! I have an assignment for school that is really got the best of me. Here is the question: (2) Write a C program using while loop(s) in combination with only the following three output statements (Each one appearing ONLY ONCE in your program): printf("* "); printf("\n"); printf(“^“); to print the pattern: ...

Sentinel while loop for C++

Can anyone tell me what is sentinel while loop in C++? Please give me an example using sentinel while loop. ...

PHP: letting your own function work with a while loop

Hi i have this code $qVraagGroepenOp = "SELECT * FROM $tabele WHERE $where"; $rVraagGroepenOp = mysql_query ( $qVraagGroepenOp ); $aVraagGroepenOp = mysql_fetch_assoc ( $rVraagGroepenOp ) and i converted that to a fucntion vraagOp("testtable","testtable_ID = $id"); function vraagOp($table,$where) { $qVraagOp = "SELECT * FROM $ta...

FPDF Header Question - Driving me crazy!

I am trying to generate a PDF that outputs Item Names onto a template PDF (using FPDI) with the Username listed on the top of each page. Every user can have a different number of items (i.e. if there are 1-4 items, only output one page; if there 5-8 items, output two pages, etc.) Here is an example of what I am trying to do: http://www...

Loops in C - for() or while() - which is BEST?

for() or while() - which is BEST? for (i=1; i<a; i++) /* do something */ OR i=1; while (i<a) { /* do something */ i++; } ...

PHP Class Variables emptied in While Loop

I've been dabbling in writing a PHP Class for a few weeks now and I like to think I've got a handle on he basics but I'm a little stumped. As a simplified example of what I'm doing: I have declared and instantiated a public variable ($myURL) in my class (someClass) and in a external file (config.php) to the class filled the variable wi...

How do I Increase the speed of this sqlite db query / object creation in Objective-C?

Hi, I have the following method which queries a sqlite db table on the iPhone it pulls about 6,000 rows from the table and then cycles through those creating 6,000 objects based on the information and stuffing them into an array. The while loop is somewhat slow (takes ~ 10 seconds to iterate through them on my device) Any thoughts on ho...