while-loop

while($row = mysql_fetch_array($query)) doesn't work in second time

别来无恙 提交于 2020-02-01 09:16:19
问题 I have: $query = mysql_query("SELECT ... "); while($row = mysql_fetch_array($query)) { first time used; } ... while($row = mysql_fetch_array($query)) { second time used; } In second time it doesn't work. Why? 回答1: That's because the internal data pointer has reached its end. To reread the query, either rewind the pointer with mysql_data_seek() , or reissue the query. 回答2: A MySQL result resource has an internal pointer, much like a PHP array, and when you have run through it once, the pointer

Java: while loop not working

假装没事ソ 提交于 2020-01-30 13:26:29
问题 I want to check the users input when a new game is created, and see if it is y, n, or neither. For some reason it skips the while loop all together and just outputs "Welcome to Questions." import java.util.Scanner; public class Questions { public static final Scanner INPUT = new Scanner(System.in); private boolean ans; public Questions() { while (ans = false) { System.out.print("Do you want to start a new game (y/n)?: "); String input = INPUT.nextLine(); if (input == "y"){ ans = true; //some

Java: while loop not working

我的梦境 提交于 2020-01-30 13:26:09
问题 I want to check the users input when a new game is created, and see if it is y, n, or neither. For some reason it skips the while loop all together and just outputs "Welcome to Questions." import java.util.Scanner; public class Questions { public static final Scanner INPUT = new Scanner(System.in); private boolean ans; public Questions() { while (ans = false) { System.out.print("Do you want to start a new game (y/n)?: "); String input = INPUT.nextLine(); if (input == "y"){ ans = true; //some

Cin loop never terminating

馋奶兔 提交于 2020-01-30 08:35:05
问题 I'm having trouble getting my cin loop to terminate in my program. My program uses Linux redirection to read in input from the file hw07data, the data file look like this: 100 20 50 100 40 -1 A34F 90 15 50 99 32 -1 N12O 80 15 34 90 22 -1 The first portion is the total points for the class, the next lines are the students ID number followed by their scores, all terminated by -1. My issue: my while loop never terminates when i run the command ./a.out < hw07data , could anyone look over my code

R 3.4.1 - Intelligent use of while loop for RSiteCatalyst enqueued reports

喜夏-厌秋 提交于 2020-01-30 05:24:27
问题 Actual I have been using the RSiteCatalyst package for a while right now. For those who do not know it, it makes the process of obtaining data from Adobe Analytics over the API easier. Until now, the workflow was as follow: Make a request, for instance: key_metrics <- QueueOvertime(clientId, dateFrom4, dateTo, metrics = c("pageviews"), date.granularity = "month", max.attempts = 500, interval.seconds = 20) Wait for the response which will be saved as a data.frame (example structure): > View

Determine when two consecutive cells are blank

北慕城南 提交于 2020-01-26 03:28:15
问题 The following While loop is meant to iterate down a column until two consecutive blank cells are found. It exits as soon as curCell is empty, disregarding the value in lastCell. While debugging, I have verified that lastCell has a value and is not empty, but the loop still exits. Something wrong with my And statement? While (lastCell <> "") And (curCell <> "") lastCell = curCell ActiveCell.Offset(1, 0).Select curCell = ActiveCell Wend 回答1: You should use Or instead of And. And requires both

A foreach loop in a while loop

懵懂的女人 提交于 2020-01-25 13:05:20
问题 I'm trying to convert wordpress tags (and other input) to html classes. First I query the posts, set them in a while loop and in this while loop I convert the tags to usefull classes. I've got this right now: <?php while ($query->have_posts()) : $query->the_post(); $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $thetags = $tag->name . ''; echo $the_tags; $thetags = strtolower($thetags); $thetags = str_replace(' ','-',$thetags); echo $thetags; } } ?> <!-- Loop posts

A foreach loop in a while loop

假如想象 提交于 2020-01-25 13:05:10
问题 I'm trying to convert wordpress tags (and other input) to html classes. First I query the posts, set them in a while loop and in this while loop I convert the tags to usefull classes. I've got this right now: <?php while ($query->have_posts()) : $query->the_post(); $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { $thetags = $tag->name . ''; echo $the_tags; $thetags = strtolower($thetags); $thetags = str_replace(' ','-',$thetags); echo $thetags; } } ?> <!-- Loop posts

java: while loop - statement with a semicolon before going into statements between curly braces?

荒凉一梦 提交于 2020-01-25 10:07:44
问题 I was looking at another page here on stackoverflow and came across a working implementation of cycle sort, but I don't understand how a statement with a semicolon can exist before the curly braces in a while loop. I thought that the while loop is supposed to completely terminate and take no further actions once it finds a statement with a semicolon, so how is it that the code within the curly braces is getting executed? At first glance, I would interpret this as "var" gets incremented with

java: while loop - statement with a semicolon before going into statements between curly braces?

≯℡__Kan透↙ 提交于 2020-01-25 10:07:28
问题 I was looking at another page here on stackoverflow and came across a working implementation of cycle sort, but I don't understand how a statement with a semicolon can exist before the curly braces in a while loop. I thought that the while loop is supposed to completely terminate and take no further actions once it finds a statement with a semicolon, so how is it that the code within the curly braces is getting executed? At first glance, I would interpret this as "var" gets incremented with