Most voted "while" questions
Use this tag when the question primarily involves logic and/or command structure. Effectively, while is a repeat loop used to iterate matrices, vectors, or to another end that basically has a single component, the stop condition.
Learn more…332 questions
Sort by count of
-
0
votes2
answers105
viewsPrint results in a feed interspersed with horizontal spaces (blank line)
I set up a news feed that reads the information in a database, but I need that instead of each line being printed one after the other, I need to be given an interval between each print with a blank…
-
0
votes1
answer1432
viewsHow to transform a while structure into for? And vice versa?
I am in need of an explanation on how to turn a structure into while to for and vice versa. I thank anyone who can help!
-
0
votes1
answer85
viewsDoubt while loop
I have the following code: # -*- coding: utf-8 -*- def soma(lista): soma_num = 0 while soma_num <= lista: soma_num += a return soma() a = [1, 2, 3, 4] print(soma(a)) I know it will give error on…
-
0
votes1
answer181
viewsUnlink is not working within loop
I have been trying for some time to delete images from a folder through an unlink within a loop,in the case while,but I’m facing the error: PHP Warning:…
-
0
votes3
answers101
viewsWhat condition can I develop to avoid duplicating values?
How to avoid duplicate numbers in this random generator? var soma = 0 while (soma < 1000) { soma += parseInt(Math.random() * 100) document.write(soma + "<br>") } As it goes running, it…
-
0
votes1
answer43
viewspq the input x iteration DOES NOT interfere with the while loop x iteration, where it is the same variable?
I am learning programming logic with Python and I don’t understand how the input x DOES NOT interfere with the iteration of the x from the while loop, which is the same variable. Please explain to…
-
0
votes0
answers162
viewsWhile Times Limit - Arrayiterator
I’m doing two queries in different BD tables to generate a page with different views depending on the result. For this, I am mounting in each query a different While. In fact, one is within the…
-
0
votes2
answers39
viewsSkipping line before time
<script> var i = 0; while(i < 100){ n = 1; resultado = n + i; if(0 === (i%10)){ document.write(n + '-' + resultado + '<br>'); }else{ document.write(n + '-' + resultado + ' '); } i++;…
-
0
votes1
answer742
viewsIF inside while PHP/MYSQL
I’m listing some results within while my goal is that when any of the variables I list in while come empty, it lists only those that come with content. ps. is a polling system, I put to register 4…
-
0
votes1
answer60
viewsPrint all images from another table without repeating the title
I have the two tables below table IMAGES id_imagens | diretorio_imagem | post_id 1 imagem1.jpg 1 2 imagem2.jpg 1 3 imagem3.jpg 1 4 imagem4.jpg 1 5 imagem5.jpg 2 6 imagem6.jpg 2 7 imagem7.jpg 2 8…
-
0
votes1
answer978
viewsDetermine the largest prime number after a value is given using while function
I have to create an exercise to discover the largest prime number after being provided me a certain value using the while function, which is wrong in what I created below?? def maior_primo(n): x=0…
-
0
votes1
answer527
viewshow to group mysql while result inside php table
Good afternoon someone can give me a light I’m trying to organize the data inside the while, Today I can take the data and put it in the normal table only my problem is when there are many items…
-
0
votes1
answer96
viewsJavascript + PHP
Hi, I need your help; I have my While in PHP, listing all the materials, their quantities and a space where the Total is calculated as the quantity of the product increases. Here my PHP: <?php…
-
0
votes3
answers86
views -
0
votes2
answers559
viewsAlgorithm that reads three numbers and displays the result of the sum of the first two and multiplied by the third
Follow my code below, however does not return correct the result, if I put as input 2, 2, 3 was to appear 12, but appears 6 public class Exercicio2 { @SuppressWarnings("unused") public static void…
-
0
votes2
answers336
viewsHow to update records marked with checkbox at a while
I am not being able to update the fields that are only selected by CHECKBOX, which I was able to develop right below: BD.SQL CREATE DATABASE IF NOT EXISTS `seq_acessos` DEFAULT CHARACTER SET utf8…
-
0
votes2
answers880
viewsEnd loop when an entry is empty
I have the following situation: A repeat loop that asks for name, and 2 notes, where the data input should end when an empty name is read, but in the way below the second time the program runs the…
-
0
votes1
answer224
viewsproblem with existing condition in while python. Turtle
I’m having a hard time solving an exercise in a programming book. The exercise asks me to create two turtles and move them randomly, so that each turtle walks 50 units forward, then turn either…
-
0
votes3
answers454
viewsLoop of repetition in C
Hello, I’m a beginner in programming and I have a question: I’m making a program that has a menu and a registration to be performed by the user. I would like to know how to make the menu of the…
-
0
votes1
answer98
viewsWhy does this infinite loop happen?
I made this code but it keeps giving endless loop and I can’t fix... #include <stdio.h> int main (){ int x, z; while("x=100; x!=65; x-=5"){ z=x*x; printf("%d --> %d\n", x, z); } }…
-
0
votes1
answer65
viewsI can’t do the limitation
Hello I have the following problem: When I press the button it generates 24 more images, this is not my wish, I want you to continue only 24 and just change for the following. (see here) code:…
-
0
votes1
answer105
viewsHow can I build a loop with the bootstrap grid in several sizes?
I am currently working with wordpress and came to the following doubt... My current loop is like this... (8 Items) COL-MD-6 COL-MD-6 -------------------------- -------------------------- COL-MD-6…
-
0
votes0
answers363
viewsAbout foreach array while loop for...to leave results in alphabetical order
<? $n = 0; $limite = 10; while ($n <= $limite-1){ $dates = array($user["members"][$n]["rank"]); foreach ($dates as $value){ echo $value; } $n++; } ?> it returns the following value: 87 41…
-
0
votes1
answer26
viewsDelete the last number I typed
Friends, one more question ( ). Observe the following Code: Numero = int(input('Digite um Numero')) inteiro = [] inteiro.append(Numero) while Numero>0: Numero = int(input('Digite um Numero'))…
-
0
votes1
answer1025
viewsAveraging the sequence of while
I’m solving college exercises, but I got caught up in one: The exercise asks me to calculate the even numbers between two integers, and that at the end, I do the arithmetic mean between the pairs.…
-
0
votes2
answers112
viewsHow to use "for" and "While" to capture cell tags from various tables in an html file?
I have several HTML files that I need to capture the data inside the tables, to launch in the database, but I’m not able to navigate in the html tree to find the tags that are cells, the html is…
-
0
votes0
answers117
views -
0
votes1
answer60
views -
0
votes1
answer91
viewsError in capturing information in files using the fseek() function... What’s the problem?
I’m having trouble with an Info capture function of a file with the fseek() function [I don’t know if there is a better alternative...]. Getting back to the problem, I want to read a file that has:…
-
0
votes2
answers48
viewsError picking a select result
Can someone help me with this code. Makes that mistake: Warning: mysql_fetch_array() expects Parameter 1 to be Resource, Boolean Given in /var/www/xxx/teste.php on line 14 Notice: Undefined…
-
0
votes1
answer27
viewsPlace the Angularjs switch function inside while php loop
I put the swicth function of angular, inside while in PHP. When executing only the first loop that works the rest of the function does not work. I’ve put the different ng-app and ng-controller names…
-
0
votes1
answer819
viewsHow to hide table columns if there is no record in the database?
<?php // Pega o id do produto vindo da URL $id_produto = $_GET['produto']; ?> <table width="100%" class="table table-bordered table-inverse table-hover…
-
0
votes3
answers666
viewsWhile loop - number counter minus 0
good night! I need to apply a loop for the user to always enter a number (via prompt), when typing 0 should appear an Alert stating the amount of numbers typed, not counting the zero. I don’t…
-
0
votes2
answers399
viewsWhile on dynamic carousel
I am trying to display the images in the Bootstrap Carrousel with while. I can access the array with all urls, but I’m not able to insert the img tag in while, I tried while with foreach to display…
-
0
votes2
answers186
viewsMake variable wait to be set by user after While? java
Hello, I want the user to set the value of a variable, but it should set it only after the while. My question is, how do you do it? Here’s the piece I’m doubting. public static void…
-
0
votes1
answer173
viewswhile (Cin >> str) An equivalent code in Python
Need to read multiple items without a fixed amount, in c++ just do while (Cin >> str) what would be an equivalent python code? has an answer in English to this same question here in the stack,…
-
0
votes0
answers35
viewsProblems with While
I am developing a page that should pull from the database the name of the content and the path of the HTML file that contains this content. In the database table there are two columns: content_title…
-
0
votes3
answers376
viewsmultiply div s repeat loop co div s
I have a list of channel names that are broadcasting a certain game on twitch.tv (api), so I can take all the channels and list the same. The question is how to put them in a div To stay in blocks…
-
0
votes2
answers417
viewswhile True inside while True
How do I end the while True session completely inside another one? Ex: I did it with break, but it’s only finishing it inside another (while True). look at an example below. while True: test =…
-
0
votes2
answers142
viewsI’m having repeat problems in python
while True: nome = str(input('nome do aluno: ')) if nome == 'sair': break elif nome in notas: print(f'\n{nome}',nome.upper()) n1 = float(input('Nota do…
-
0
votes3
answers842
viewsDo you have to make the user type the number of rows and columns of a table and this table appears in PHP?
I must create a code that the user can enter the number of rows and columns a table should have, and this table should appear to the user. I try this code here, but the table does not appear with…
-
0
votes0
answers71
viewswhile with conditions or
I have the following code: while (operacoes is not '+') or (operacoes is not '-') or (operacoes is not '*') or (operacoes is not '/'): operacoes = str(input('Escolha uma das operações matemáticas a…
-
0
votes0
answers14
viewsHelp with the while loop in a Python quiz
The intention is if the answer is s he executes that completed the registration successfully, but if it is n or other than s prints the message: registration canceled or thank you and come back…
-
0
votes1
answer400
viewsIn R: How to group the results of a loop into a rbind function?
Whereas I have a dataframe called page whose number of lines varies regularly, I wrote this code so that it fits the number of lines that my page$id owns and wrote this while so that he manages a…
-
0
votes1
answer91
viewsSelect limiting query, and does not display the latest queries
In this script, it is limited to the display of 6 queries in the SELECT variable $quantidade_pg = 6, I used the IF to inform that all news situations other than 2 (unpublished) should be displayed.…
-
0
votes1
answer928
viewsWrite the average of the numbers typed, if they are even. Finish reading when user type zero(0)
Ex) Write an algorithm that averages the numbers typed by the user if they are even. Finish reading if the user type zero. I did so: public static void main(String[] args){ Scanner x = new Scanner…
-
0
votes1
answer195
viewsSentence while - not true... understanding logic
I’m having a lot of trouble understanding why the program stops when I type n=0. when type 0 the finished turns to True, and the while logic is just this, no? I’ve run the program and it’s correct,…
-
0
votes0
answers98
viewswhile inside while not working
I’m making a table in Excel that takes the direct information of DB, my first while I’m able to pick normally, already the second is not coming, appears all blank. <?php…
-
0
votes2
answers202
viewsForce while loop output on C switch
Guys, I made a menu in C language, but I need that when the user type option 4, it comes out of the repetition loop of/while, someone can help me. Thanks again to all for participating. int opcao;…
-
0
votes3
answers639
viewsCount to 100 with PHP
I need to complete the array $resultado using the parameter $numero up to 100. For example, if $numero were 45, $resultado should have the numbers from 45 up to 100, the number 100 should also be…