Posts

Showing posts with the label while-loop

Asking for user input twice in a while loop

Image
Clash Royale CLAN TAG #URR8PPP Asking for user input twice in a while loop I'm currently doing a java project. The project involves a database about NHL Statistics and about accessing bits of information from the database through user input. I'm using a while loop to ask for user input in multiple circumstances, such as asking for the number of penalties received, the number of goals scored, amount of points etc. I am having difficulty with one specific part, it asks the user input for which statistic they want (points, goals, assists,penalties, assists, player, club). After that, if the user types player as their choice, then the system is supposed to ask the user which players statistics they wish to see. The problem is that since I'm using a while loop after the user inputs the first time, the loop is executed and the program ends before the player can input the second time. Any help would be appreciated, here is my code: import java.util.Scanner; import nhlstats.NHLS...

Why are heredoc redirections not allowed before a while loop

Image
Clash Royale CLAN TAG #URR8PPP Why are heredoc redirections not allowed before a while loop The POSIX Shell Command Language allows redirections to follow compound commands. The standard says (emphasis mine) The shell has several programming constructs that are "compound commands", which provide control flow for commands. Each of these compound commands has a reserved word or control operator at the beginning, and a corresponding terminator reserved word or operator at the end. In addition, each can be followed by redirections on the same line as the terminator . Each redirection shall apply to all the commands within the compound command that do not explicitly override that redirection. For aesthetic reasons I want to put a heredoc before my while loop as in <<'RECORDS' while foo:bar baz:quux ... RECORDS IFS=: read -r A B do # do something with A and B done because it makes the code easier to follow. However, it doesn't work in the shells I tried it (...

How to output a group, based on the same column cell, while looping it out into html?

Image
Clash Royale CLAN TAG #URR8PPP How to output a group, based on the same column cell, while looping it out into html? I want to create groups while looping all my rows from a database table. example database: id | sex | name | age 1 | male | kevin | 20 2 | male | bob | 24 3 | female | jenny | 24 4 | female | bob | 20 5 | no | gaben | 13 I want to group the entries by names. The output i'm looking for is something like this: Should output: <div id="bob"> <a>bob male 24</a> <a>bob female 20</a> </div> <div id="kevin"> <a>kevin male 20</a> </div> <div id="gaben"> <a>gaben no 13</a> </div> <div id="jenny"> <a>jenny female 24</a> </div> I was making two while loops inside of eachother. It only outputs one <div> for one name . Each div should be created for each unique name . So when someone has the same name , they should be put t...

exclude status in dropdown list

Image
Clash Royale CLAN TAG #URR8PPP exclude status in dropdown list good day im trying to exclude all "Defective" in my column status in my "mobo" table and so far this code is not working. it's still showing everyting in my dropdown list: <?php $conn = new mysqli('localhost', 'root', 'admin2018', 'inventory') or die ('Cannot connect to db'); $result = $conn->query("select mobo, status FROM mobo WHERE NOT 'status = Defective'"); echo "<select name='mobo'>"; while ($row = $result->fetch_assoc()) { unset($id, $name); $id = $row['mobo']; $name = $row['mobo']; echo '<option value="'.$id.'">'.$name.'</option>'; } echo "</select>"; ?> 1 Answer 1 ...

I want to use python “loop” for drop list

Image
Clash Royale CLAN TAG #URR8PPP I want to use python “loop” for drop list import pandas as pd import os import xlrd os.chdir('D:python') file_name='D:python\test.xlsx' sheet='test01' df=pd.DataFrame(pd.read_excel(file_name,sheet)) df.drop(list(df.filter(regex = 'Abc')), axis = 1, inplace = True) df.drop(list(df.filter(regex = 'def')), axis = 1, inplace = True) df.drop(list(df.filter(regex = 'ghi')), axis = 1, inplace = True) df.drop(list(df.filter(regex = 'jkl')), axis = 1, inplace = True) df.drop(list(df.filter(regex = 'mno')), axis = 1, inplace = True) df.drop(list(df.filter(regex = 'pqr')), axis = 1, inplace = True) I want all variables(a to r) in one list so that all above condition passed in one sentence. for this I want to use loop. Any suggestion on this. 1 Answer 1 Try like this : df=pd.DataFrame(pd.read...

How would I modify this fgetcsv to check multiple columns (not just one!)

How would I modify this fgetcsv to check multiple columns (not just one!) I have a working script below which checks a column (1) for something and if found, looks at the adjacent column (0) and does some stuff. (i've excluded stuff above the important code but it loops round every file in a directory as $thisGame or thisGameNoExtension which is the same just with no file extension! $thisGame thisGameNoExtension $csvFile = fopen("ManualRegionDupes.csv", "r"); while ($csvRows = fgetcsv($csvFile)) { if ($csvRows[1] == $thisGameNoExtension) { $primaryGame = $csvRows[0]; $fileExtension = pathinfo($thisGame, PATHINFO_EXTENSION); $fileCheck = trim(shell_exec("ls -1 " . escapeshellarg($primaryGame) . "." . escapeshellarg($fileExtension) . " 2>/dev/null")); if ($fileCheck) { echo "33[00;33m is on the Manual Region Dupes list and primary version detected. Moved to Removed ...