while-loop

While loop only retrieving one result

别等时光非礼了梦想. 提交于 2019-12-12 01:23:09
问题 UPDATE: Still can't seem to figure it out. If anyone can lend a hand, it would be appreciated ^^. I am having a problem and I'm not sure where my code is breaking down. I have a 'follow' function where you can follow different registered users. Their userID's of who you followed are stored in an array (follower_array). It's retrieving each member from the array, but of each member that's followed instead of displaying all the content, it's only displaying the 1 latest one from each member.

query inside while loop only shows 1 result

人走茶凉 提交于 2019-12-12 00:34:34
问题 i'm making a while loop in php and it all goes well but the problem is that I don't only want to get the id of the user but also some other stuff that is inside another table, so when I go ahead and make a query inside this while loop and select everything from that second table (where the id is equal to the id of the result from the first query), it only returns 1 result... So this is the code that I currently have: public function getFriends($id) { global $params; $get = $this->db->select("

Using switch statements in a while loop

可紊 提交于 2019-12-12 00:25:59
问题 I'm trying to use switch statements in a while loop in Java, but there is something going wrong. Please have a look at a sample code below which explains my problem: Scanner input=new Scanner(System.in); int selection = input.nextInt(); while (selection<4) { switch(selection){ case 1: System.out.println("Please enter amount"); double amount=input.nextDouble(); //object of scanner class break; case 2: System.out.println("Enter ID number"); break; case 3: System.out.println("Enter amount to be

perl loops within subroutines to display the longest repeating string thats selected for a particular subsection of the string [duplicate]

微笑、不失礼 提交于 2019-12-11 23:29:22
问题 This question already has answers here : Find longest repeating string based on input in perl (using subroutines) (2 answers) Closed 6 years ago . I was wondering if anyone knows how to simplify, or generalize this code. It gives the correct answer, however it is only applicable to the current situation. My code is as follows: sub longestRepeat{ # list of argument @_ is: (sequence, nucleotide) my $someSequence = shift(@_); # shift off the first argument from the list my $whatBP = shift(@_); #

Java do-while loop simple issue

六月ゝ 毕业季﹏ 提交于 2019-12-11 23:12:55
问题 I haven't coded in a few years and have been writing simple Java programs to re-familiarize myself with basic principles. However, I'm having trouble getting my do-while loop to act how I want it to. I guess I'm not understanding exactly how do-while loops work, but what I want is to gather user input from System.in as an int, and continue to ask for a valid int input if they enter some other data form. What I have is: do { System.out.print("Input: "); userOption = userInput.nextInt(); }

Can only post first result of while loop

懵懂的女人 提交于 2019-12-11 22:21:36
问题 I am using a while loop to display results from a query. The while loop is working fine. In hidden fields I would like to post the values of userID and accessID to the user details page. I am submitting the form using javascript to submit from a link. My problem is that regardless of the username I click I can only post the values for the first displayed record. What am I doing wrong? The code: <?php while($row = $result->fetch_array()) { ?> <form method="post" action="edit_user.php" id=

While loop creating duplicate records

人盡茶涼 提交于 2019-12-11 22:04:48
问题 I have a very simple query that takes two dates (start and end date, ex: 01/01/2018-01/31/2018) and then take out the week number of start and end date (ex: 1 and 5). I use while loop in order to enter all week numbers in one table (ex: 1,2,3,4,5). My while loop is creating duplicate records, like multiple records for all values. I am not sure what the issue is. Can someone suggest what I am might be doing wrong? Code: DECLARE @StartDate datetime = '01/01/2018' ,@EndDate datetime = '01/31

Coffescript Callbacks & Functions

大憨熊 提交于 2019-12-11 21:32:17
问题 I have this function and I am trying to use two large functions made up of smaller ones and one while loops. One for when it's the players turn, one when it's the opponent's turn, and a while loop when the player has won. When I run it in the browser, the buttons do not do anything. What is wrong? $attackButtonClick = (opponent) -> if playersTurn and not player.Win player.attack(opponent) if opponent.currentHealth <= 0 player.Win = true; allOff() postBattle(opponent) else playersTurn = false;

ncurses, print and contemporary acquire strings

梦想与她 提交于 2019-12-11 21:24:15
问题 A program written in C uses ncurses . A while cycle is used to continuously check if a new message is arrived in a queue: if it is, the message is printed on screen and then removed from the queue: while (condition) { if (queue_not_empty) { printw(element_from_queue); refresh(); remove(element_from_queue); } } At the same time, however, the program should be able to acquire an input string from the user and then store it in the array char message[100] through a scanw . But if I put while

How to check if multidimensional array row contains non-Zero value

只谈情不闲聊 提交于 2019-12-11 20:39:41
问题 Just a short question regarding multidimensional arrays in C#. How can I check if one row of a multidimensional array contains a non-Zero value? In Matlab, the "any"-command does exactly what I need. Finally I need to put the request into a while condition. Means in Matlab: while(any(array[1,2,:])) --> which means: while(any-entry-of-the-row-is-not-Zero)... I tried already the Array.Exists() or Array.Find() but it seems to work only with one-dimensional arrays. Thanks 回答1: You have a couple