while-loop

PHP echo xyz if rows in loop contain no data

I am trying to echo some text if my loop returns with no data but can't get it do work. I have tried a few things but no luck. my code: $result = mysql_send("SELECT * FROM datatable WHERE id='". $_SESSION['id']."'ORDER BY id ASC LIMIT 2"); while($row=mysql_fetch_array($result)) { $a = 1; extract($row); echo 'Trans ID:...

While loop into 2 different divs?

Hey all, I've got an about page, and two HTML columns and I want to while loop the contents of my mysql query into BOTH columns, even though they are defined as two different divs. What I was thinking of doing is somehow dividing the amount of rows in the mysql database by 2, and then showing half and half, but I'm not sure how to do thi...

[Problem Solving] PHP while loop and table header only showing if a db value is set..

Hey everyone. Here is my code. <table border="1" style="width:800px"> <?php $schedule_db = mysql_query("SELECT * FROM schedule WHERE '00:00' is not null and '01:00' is not null and '02:00' is not null and '03:00' is not null and '04:00' is not null and '05:00' is not null and '06:00' is not null and '07:00' is not null a...

c#.net Error Looping throgh an Enumerator

I have created a .bat file that displays a servers terminal Service SessionID and Username. Im Displaying the Information in a datagrid Here is the output of the .bat file: C:\Documents and Settings\adcock>qwinsta /server:ilsap01 SESSIONNAME USERNAME ID STATE TYPE DEVICE console ...

Should I use `while (true)` or `for (;;)` (in languages that support both)?

Possible Duplicate: When implementing an infinite loop, is there a difference in using while(1) vs for(;;) vs goto (in C)? In languages where while (true) or for (;;) both mean "loop forever", which should I use? ...

Why is this variable being changed?

tokens_raw = {"foo": "bar"} tokens_raw_old = { } while not tokens_raw == tokens_raw_old: tokens_raw_old = tokens_raw # while loop that modifies tokens_raw goes here; # tokens_raw_old is never referenced print tokens_raw_old == tokens_raw This outputs True after the first time for some reason. tokens_raw_old has the same...

Empty while loop not checking condition

In a multithreaded C++ program, I have the equivalent of this running in one thread: while(obj->member) { } // waiting for obj->member to be set to false in another thread and in another thread, obj->member is set to false. Even when it's set to false, however, the loop doesn't break. If I change it to this: while(obj->member) { Slee...

Is there a better way to group query results with a loop in PHP?

Hello, that´s my first question in stackoverflow. I have two MYSQL tables: categories and products. I manage the query results with a while loop in PHP to group every category with its products. It´s the first time I do something so, and I think I made it very "crafty/hardcoded" (Sorry for my English). I think that should be a better wa...

While loop execution time

We were having a performance issue in a C# while loop. The loop was super slow doing only one simple math calc. Turns out that parmIn can be a huge number anywhere from 999999999 to MaxInt. We hadn't anticipated the giant value of parmIn. We have fixed our code using a different methodology. The loop, coded for simplicity below, d...

loop for these iterations

I am trying to loop the below iteration, the code is below and i will try and break it down aswell. <?php function intr($LoanRequired, $TermMonths, $MonthlyPayment, $rate) { $intr= $LoanRequired * pow((1 + $rate), $TermMonths) + $MonthlyPayment * ((pow((1 + $rate), $TermMonths) - 1) / $rate); return $intr; } $x0=0...

Cant stop a while loop with a button

Hello. Im trying to write a program which moves the mouse every 3 minutes (to stop a screen saver coming on) but I want to be able to stop and start it at will. As you can see below I have create the buttons and method but when you click run it steps into the while loop and because its in effect an infinite loop it won't look and see if...

how does the retweet mechanism work on twitter?

I'm creating similar thing to twitter retweet function! This is my database table for tweets (status messages): ID || USER_ID || TWEET || RETWEET_ID || RETWEET_NAME || DATE What I'm trying to find out is, if the logged in user retweets something, when they refresh the page I don't want them to see the retweet button (because obvious...

fflush and while loop

Hello, I have been trying to use fflush to make a progress bar. To test fflush, I wrote the small code below. It works as it supposed to when I uncomment "sleep(1);" but it works in an unexpected way if it remains commented out. It prints the first dash, waits than prints all remaining 9 of them and quits. I don't understand why it...

Python - Write a function that takes a string as an argument and displays the letters backward, one per line.

This is an exercise from "How to think like a Computer Scientist". I am learning Python/programming and I'm not sure how to do accomplish this task. Here is an example in the book that displays the letters forwards, I can't figure out how to get the opposite effect. Has to use a while-loop. fruit = 'banana' index = 0 while index > ...

If statement or while loop failing on me in php

I am fairly new to coding in php and have come accross a bit of a problem which I think is very simple. I am trying to capture the IP address of anybody that visits my website and stores that in my database. The code is as follows, I am not even sure the code will work but I do get the following error Parse error: syntax error, unexpecte...