Questions tagged [while-loop]

The concept of a while loop is commonly found in various programming languages as a way to repetitively carry out a specific set of instructions for as long as a specified condition remains true.

Strategy to implement when a web element is appearing and disappearing twice

I am currently facing a challenge and I need help resolving it. Using Selenium and Helium, I am conducting tests on a web application. During the testing process, the web app displays a screen blocker that appears and disappears twice. I need to wait fo ...

What is the code to continuously click on the "Next" button in playwright (typescript) until it is no longer visible?

Currently, I have implemented a code that clicks the next button repeatedly until it no longer appears on the pagination. Once the last page is reached, I need to validate the record. The problem arises when the script continues to search for the locator ...

Count the total sum by date and group them while using PHP

Within my MySQL table, I have the following data: user | open | date --------------------------------- User1 | 1 | 2017-05-19 User2 | 1 | 2017-05-19 User3 | 1 | 2017-05-19 User4 | 1 | 2017-05 ...

How often do you want to see just a single row displayed?

I have a situation where I need to compare data between two SQL tables - one containing manually inserted data and the other with data automatically inserted by a script. To ensure that the script is functioning correctly, I want to verify that both table ...

Sorting and breaking a while loop based on a variable in PHP

I'm facing an issue that has been puzzling me for the past two days. As a newbie in php, I am struggling to understand why my while loop is returning multiple select fields for each option within a select field. For example, when I have a "choose colo ...

Navigating through the outputs from a MySQL query

There is a specific functionality I am trying to achieve, although I may not have the exact terms to describe it. Let me explain what I need in detail. Initially, there is a variable named $id, which essentially represents $_GET['id']. For insta ...

PHP - Monitoring for File Existence

I'm trying to execute an exe file that generates txt files and then check if those txt files have been created. When I use xampp, I've tried dragging a test.txt file into the php scripts directory, but it doesn't work correctly. Also, if I ...

What is the most effective method for locating a specific string within a text file using Python?

Exploring methods to search for a string in a text file using Python, what is the most efficient approach? (considering speed and resource utilization) My initial attempt was as follows. file = open('/home/socfw/src/edl/outbound_monthly.txt') inputIP = ...

Executing a while loop that contains conditions for if and elif statements

Here is a snippet of code from an automation program designed to click on specific areas of the screen based on certain conditions. The goal is for this block of code to repeat until it reaches the position with coordinates (867,647) and meets all if/eli ...

Incorrect order shown by echoing in PHP MySQL while loop with if condition

I am currently working on a task involving echoing a list from MySQL using a while loop. However, the list appears to be in the wrong order when viewing it here on . Why is this happening? The purpose of the if statements is to ensure that the top and bot ...

Find the sum of every combination of numbers in the array

I've reviewed my code countless times and I'm stumped by the issue. My code is designed to calculate all possible sums of numbers within an array. It works perfectly when there are only 3 numbers in the array, but once I add a fourth number, it i ...

Reached max call stack size with just 1 loop iteration

After encountering a call stack size exceeded error in my while loop, I attempted various unsuccessful methods to limit it. Now, the code snippet below reflects my current approach: var hasnext = true; while(hasnext) { options.form['formBusca:dataS ...

PHP Issues with PHP While and ForEach loops causing unexpected outcomes

I am having trouble with my code logic. Currently, I am using a while loop to retrieve associated records for each meal_id. However, my foreach loop is not functioning as expected. My aim is to display the meal information first and then list the meal item ...

Steps for creating a while loop that continuously inputs prices until the user enters 0:

I am hoping to create a simple Python code that allows users to input prices from a shopping trip, with the loop ending when they input 0. Once the loop stops, I'd like to display the total number of items, average price, and total price using an else stat ...

`Calculate elements as long as the predicate remains true`

I've got a series of JSON objects that look like this: {"id":"da1234563","message":"brown fox jump over a red log"} {"id":"da1234564","message":"brown fox jump over a red log"} ...

The login form constantly displaying the message "Incorrect Login Information"

<?php include 'header.php'; error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); $con = mysql_connect("localhost","root",""); $db_selected = mysql_select_db("layout",$con); $name = $_POST['name']; $password = $_POST['password']; if($_POST["submit ...

Pandas in an endless loop?

How can I identify and resolve a potential infinite loop in my code? This is the code snippet in question: new_exit_date, new_exit_price = [] , [] high_price_series = df_prices.High['GTT'] entry_date = df_entry.loc['GTT','entry_date'] window_price_series ...

Endless cycle within the while loop without any obvious cause

I've been tinkering with a timer and thanks to some feedback I received in this community, everything is running smoothly. Here's what the current version looks like for reference: https://i.stack.imgur.com/Qd7ll.png Here's a snippet of my code (please k ...

Dealing with iterations and merging data in PHP

I am working with a table that looks like this: author_id author_state author_name 1 CA Hello 2 MI World 3 CA How 4 MI Are I would like to know how I can ...

What are the steps to start running the while loop?

To provide more clarity: I am developing an intersection control system for cars where each car must register its address in a shared list (intersectionList) if it intends to cross the intersection. If cars are on road piece 20 or 23, they add their addre ...

Creating a receipt program in Python and protecting previous data from being overwritten

I am currently learning Python and attempting to create a program that generates an invoice listing all items, along with their prices and quantities. Each item should be displayed on a separate line. While I have managed to print each item in a line, I a ...

Create several CSV files using MySQL and PHP

I've created a PHP script that is supposed to take an array and generate a CSV file for each element in the array. However, there seems to be an issue as it's not saving any files in the specified directory. Strangely, no errors are being returned either. ...

What method yields more efficient results when working with arrays?

Even though I often use foreach and while loops, I've been curious about whether there is any difference in performance when using the for(i=0;i<varlength;i++) loop. Can you explain how PHP processes for() and foreach() loops differently? ...

Navigating through a series of URLs using Selenium

I am encountering difficulties with looping through a list of URLs using selenium. The problem seems to lie within the #Second Part section of my code. Currently, the length of the linklinkfin list is 9, but this number can fluctuate as more URLs are gathe ...

"if the condition is not met, the outcome will not be shown in the while

I have a looping structure that includes conditions for if, else if, and else. However, I have noticed that the else condition at the end of the loop is not being executed as expected. I am currently investigating why this might be happening. Here is the ...

Generating JSON using while loops and foreach loops in PHP

Currently, I am in the process of updating a PHP application that generates JSON data on the server side. {"by":"Industrie LLC","dead":false,"descendants":396,"id":"396","kids":[1,396],"score":396,"time":"396","title":"Industrie LLC","type":"comment","url ...

Is there a way to simulate pressing arrow keys randomly using Selenium in Python?

My current project involves creating a program that can play the game 2048 by randomly choosing arrow keys. I attempted the following code snippet: moves = [htmlElem.send_keys(Keys.UP),htmlElem.send_keys(Keys.RIGHT),htmlElem.send_keys(Keys.DOWN),htmlEle ...

Look up and access the file

My latest script is designed to search for a specific file in the current directory. If it doesn't find the file, it will move up one directory and try again. The script functions properly when the file is found. However, if the file is not present, ...

When the statement is enclosed within a while loop, an empty tag is not

Working on a custom website for a non-profit organization and I'm stuck on the search page. Here's what's going on... The search results are showing up, but when there are no results, nothing is displayed. I can't seem to figure out this issue. while($r ...

What is the best way to utilize the data in a file as a parameter?

I recently installed AutoKey on my computer with the intention of being able to run python scripts using keyboard shortcuts. Specifically, I wanted to create a script that would simulate pressing the "d" key followed by the "s" key in a loop, with the abil ...

Enhancing a PHP loop with preg_replace or sprintf to substitute MySQL data with tags embedded in a string in the ##tag## format

Let's say I have received an array from a database containing: $row = array("percent" => "33%", "name" => "30 Cups", "price" => "$16"); In addition, let's assume there is a string like the following: $string = "Take ##percent## off ou ...

Display a JavaScript dialogue box containing a PHP variable

Is there a way to display the correct JavaScript box when using a While loop in PHP? Here is the code snippet: while($result= mysql_fetch_array($data)){ <tr class="<?php echo $style;?>"> <td><?php echo $result['commissie'] ...

What is the best way to set a Python Dataframe 'column name' as a variable consisting of two strings?

I'm currently working with a DataFrame of Stocks where the columns are labeled as 'SMA100915', 'SMA500915', and so forth... The column df['SMA100915'] represents the Simple Moving Average value of the stock at 09:15 AM. I ...

Avoid selecting an element within a While loop when launching a popup using selenium. Issue with the While loop functionality

A loop is implemented to scroll through a list of names on a web page and click on each "Add" button next to the name. The functionality works correctly, ensuring all buttons are clicked. wait = WebDriverWait(driver, 30) i = 1 while i <= limit: i = ...

Different ways to change the name of an element within a loop in Python 3

I've been attempting to develop a basic calculator, and I'm facing an issue with dynamically changing my object's name within a loop. RoR = RoR + 1 "C{0}R{1}".format(CoC, RoR) = int(input("Please enter the number for Row {0}, Column {1}: ".format(RoR, CoC ...

PHP - Utilizing a while loop to dynamically wrap content in a

I am facing an issue with wrapping the date and all events in one day within a div called "obal_date". The current implementation is not working as expected. The number of events can vary, but I need to group them by date. Can someone help me achieve this? ...

How to show a single column in a while loop with PHP

After extensive searching, I have yet to find a satisfactory answer. Take a look at the MySQL table example below: id | Name | Country 1 | User1 | India 2 | User2 | India 3 | User3 | India 4 ...

PHP code contains a while loop that is responsible for outputting

As a newcomer to PHP, I've dedicated countless hours to researching and troubleshooting an issue with joining tables to populate a client profile page with multiple transactions from a transactions table. The rest of the page is functioning correctly with ...