Most voted "if" questions
The "if" statement is a control structure in many programming languages that alters the execution flow depending on a binary condition - also known as Boolean logic. This tag should be used when the question is related to the use and/or performance of the "if".
Learn more…467 questions
Sort by count of
-
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
answer585
viewsMake a denial in an IF codition
I have the following condition IF: (ClientesBDM.getNomeEmpresa().toString().equals(ClientesBD.get(1).toString())) How can I verify if the variables are different, ie deny this condition in the same…
-
0
votes3
answers119
viewsError in the Checkbox
I need to make a while in the PHP: while($lo = mysql_fetch_array($ro)) { $id3 = $lo["id"]; $nome_menor = utf8_encode($lo["nome_menor"]); This is ok! This shows the name of the companies listed on…
-
0
votes3
answers2371
viewsHow to use one if inside the other?
The problem is the following 2 football teams, wanted to create a decision where it would show "Brazil won" or "Argentina won" or "There was a draw". But I can not create three decisions, follows…
-
0
votes2
answers728
viewsSwap elseif code for switch case
I’m having trouble modifying a code I made in else if for switch case. I’m not getting the code to work, he gets values and operation by $_GET and does the selected operation: I leave the code here:…
-
0
votes2
answers1105
viewsAlgorithm implementation in Visualg
Make a program that receives two numbers and perform one of the operations listed below according to the user’s choice. If an invalid option is typed show error message and end script execution. The…
-
0
votes1
answer6172
viewsIF CONDITIONS STRUCTURE AND IF WITHIN ANOTHER
How is the structure to put 2 conditions in the IF? if (digitalRead(0 && 1),HIGH) would look like this?? And I can put one if inside another? for example ''if sensor 1 is high-rise claw,…
ifasked 6 years, 11 months ago vitor seida 3 -
0
votes4
answers437
viewsError checking IF with array in PHP
I’m trying to make a if within a foreach and the situation is as follows: I have a array who I called $plates who returns like this: array(2) { [0]=> array(1) { ["chave"]=> string(1) "1" }…
-
0
votes2
answers273
viewscomparing a variable with a vector or list
Usually to perform a conditional using an array or a list and need to perform a for and perform the if line by line in this way. //sendo item uma string e listaItens um List<String> for(String…
-
0
votes1
answer33
viewsSend the form to different addresses according to zip code
I have a form that calculates the delivery rate according to the zip code, until then everything works 100%. My client is opening his business in another area and wants the orders to be sent…
-
0
votes1
answer231
viewsHow to get first value returned by foreach
Personal I am new in programming and I am trying to solve my problem with foreach... I have a foreach that returns me the groups of photos that have photos in them... however I need to take the…
-
0
votes2
answers922
views -
0
votes2
answers59
viewsHow to make the site perform a code withdrawal with a particular user?
Good morning, I have an administrative access page for the Adms of my site but have a part of the code in one of the pages, to create and modify users and passwords, that I would like to appear only…
-
0
votes1
answer86
viewsError creating child node, generalized list
The error is found in else of the method criarFilho, I was able to locate it but I can not find solution for it. The debug Dev-C++ does not point out anything. #include <stdio.h> #include…
-
0
votes1
answer97
viewscheckbox to check whether it shows field or not
I’m working on a registration form with the birth certificate number on it. As you may already know, there is the old format of certificates, with the notary’s name, term, book and sheet (4 fields),…
-
0
votes1
answer59
viewsCounters are not being incremented in code
I am facing some difficulties with the code snippet below: The call of this function is: cache = OperaCache(true , endereco, op, cache, descricao, read_hits, read_misses, write_hits, write_misses);…
-
0
votes2
answers558
viewsMultiple if in one SQL condition
I’m trying to use 2 ifbut the result always returns empty, when I use only one if he will. SELECT aci_codigo, aci_valor_pagamento, bai_fk_pes_codigo, aci_tipo_pagamento, aci_fk_ftm_codigo,…
-
0
votes1
answer46
viewsIf loop registration error
I have a registration form: <form action="Cadastro.php" method="post"> Nome de Usuário: <br> <input class="form-control" type="text" placeholder=" algo parecido com o seu nome"…
-
0
votes1
answer212
viewsIF condition - Good use practice
During an encoding I had to carry out the development in the following way: IF (Condicao1 = True) IF (Condicao2 = True) IF (Condicao3 = True) Imprime(Mensagem); The way I’ve accomplished is…
-
0
votes1
answer28
viewsI cannot declare variable inside id
@$c_id = $_POST['numero']; @$data_aa = $_POST['data_aa']; // Data esta vazio if($data_aa == ''){ $var = "oi"; echo "$var"; } If I put the variable $var outside the if(), works normally.…
-
0
votes1
answer263
viewsIf it works but Else doesn’t
Then, the code below (is complete in https://codepen.io/RaoniSousa/pen/Zpkxbb), the if works but this Else No, what is wrong? I would like it to work like this one, in the "NAME" input by scrolling…
-
0
votes0
answers21
viewsCode does not execute a second " var = getchar(); " if an if is true
Why the code below does not allow me to fill in the 'ext' variable if the established condition has been accepted? #include <stdio.h> #include <stdlib.h> void main(){ char ext; char dif;…
-
0
votes1
answer34
viewsHow to condition email sending content with a chosen variable in the form?
I am trying to condition the email sending format by to a certain option chosen by the user, in the Subject / Script : If the option is SCRIPT, the contents of the $html variable will be sent. If it…
-
0
votes1
answer201
viewsCorrect use of "goto" with "if Else"
I have a question about the correct use of the "goto", I made a small example that illustrates my doubt: <?php $valor01=10; $valor02=8; if($valor01 > $valor02) { echo "valor01 é maior que…
-
0
votes1
answer565
viewsHow do I run the Menuiten.Click event in an if? Delphi loop
I’m putting together the login part of my system, only I’m facing a big problem. My cancel button from the login screen needs to receive two features. The first is that being clicked before the main…
-
0
votes1
answer241
viewsTaglib - Condition test between JSP and MODEL
I am trying to make my JSP (index.jsp) execute a condition (if) with taglib, to decide which menu it will import, depending on an attribute (Boolean)) that is in the model (user.java). I have…
-
0
votes1
answer53
viewsPHP error when host changes
Good afternoon, I used an online host with php 7 and I had the following syntax if(!saber_se_não_existe) {} It always worked as well as this if(saber_se_existe) {} So much so that I rediscovered my…
-
0
votes1
answer74
views -
0
votes1
answer27
viewsInserting Data Conditionally in MYSQL
I have a table: conluna1, column2, column3.. The first two columns have integer data, 0 and 1, while the third column is without even a record. I would like to fill this column according to one…
-
0
votes2
answers77
viewsAlgorithm problem
Statement: Read 3 integers and order them in ascending order. At the end, show the values in ascending order, a blank line and then the values in sequence as read. public class ex10 { public static…
-
0
votes0
answers26
viewsReplacing If/Else in Javascript
I am creating a form that will have several checkbox: <div class="checkbox"> <label> <input name="mini" id="SistemaRestauracao" class="mini" type="checkbox" value="1"> <b>…
-
0
votes1
answer174
viewsHow to replace/optimize multiple ifs in C?
I’m a beginner in C language, I’m doing an activity that is to register students and averages in a double-chained list, everything is working, however I believe I’m using too many ifs, there is some…
-
0
votes2
answers69
viewsCreating rule to create time based on delivery rate
I have a condition in my form that calculates the delivery time of orders, follows below the rule: date_default_timezone_set('America/Sao_Paulo'); $Agora = date('H:i:s'); $HoraServico =…
-
0
votes2
answers498
viewsHow to use if Else in the code below
Starting I type the artist’s id and the other data, then I will enter the repairman’s id, I need that when typing the repairman’s id, if it is equal to the artist he should not accept and ask for…
-
0
votes1
answer31
viewsPutting minutes into working time
I have the following code, where determines the time of operation of Delivery. Follow code: function delivery(){ var cep1 = document.getElementById("cep1").value; var cep2 =…
-
0
votes2
answers1155
viewsHow to declare IF in Ionic
I am with the following code, it checks the value of _meditaTotal if it is greater than 70 the icone variable gets 'green', if it is lower q 70 and greater than 50 icone variable gets 'yellow' and…
-
0
votes1
answer181
viewsUse the split() and if method to create a statement that prints the words that start with’s'
I have the following string: string_1 = 'Print only the words that start with s in this sentence' and I need to use the split method and an if to output only the words started in s. But I have no…
-
0
votes3
answers158
viewsAccess a value on an if condition
Is there any way to access a value passed on the condition of a if? For example: a = int(input('Digite um numero: ')) b = int(input('Digite outro numero: ')) if((a-b) > 0): print(f'O numero…
-
0
votes1
answer52
viewsUpdate variable in IF
Good morning, I am unable to update a variable within the IF structure and use it later in my code. Follows excerpt from my code: while ($dado_participante = mysqli_fetch_array($qry2)) { //REGISTRO…
-
0
votes1
answer56
viewsWork in C "Bank" giving error
Hello I am doing a work in c and is giving the following error: after I make the Deposit/ Withdrawal instead of going back to menu the program asks to type again. main(){ int matriz[5][2],i,…
-
0
votes1
answer280
viewsEven numbers in an array with for - PHP
Hello, I would like to understand where my code is wrong. I need to filter only the even numbers of the array using for. But it returns the following answer to me - "The filter is not working very…
-
0
votes1
answer498
viewsRedirect pages using if, Else if and Else attributes what is wrong?
my php code <?php include "conectar.php"; //comando para iserir dados direto do formul?rio para o banco de dados $nome=$_POST["nome"]; $cpf=$_POST["cpf"]; $identidade=$_POST["identidade"];…
-
0
votes0
answers65
viewsDisplay an image if the value "7" is in the "Code" Row
I appreciate the help you will offer me. I have tried many things, but now I am not moving forward at all. I managed to put this code but it doesn’t show me any picture. Up on top of me $results =…
-
0
votes1
answer404
viewsC# - If in Combobox Exercise Caelum
Good afternoon guys, I’m already a few hours trying to solve this C# workbook exercise of Caelum, but I believe I am far from solved. I would like to know how to use an IF within a Combobox to make…
-
0
votes3
answers836
viewsShow button according to php parameter condition
I wonder if it is possible to make the button appear only if the parameter is true. Through the URL comes the parameter ../usuario?id=1¶metro=1 I tried that way but I couldn’t <?php…
-
0
votes1
answer28
viewsCreate a conditional to print the media and standard deviation on the screen
I would like to create a conditional for average and standard deviation of a given group. I usually do this by dividing subsets, but as there are many categories I thought would be better with a…
-
0
votes1
answer327
viewsphp, bring multiple rows from one linked table to another single id table
I’m having a hard time retrieving information. In the data for printing, I need to show in the variable $comp when she belongs to the same id_cadastro that I am consulting, so far everything well,…
-
0
votes2
answers76
viewsGoing into if wrong
I made this code and expected it to return me 'Jedi Master', but always returns 'Intermediate'. First I had done using switch-case instead of if-lse and it always returned me 'Invalid' (in the case…
-
0
votes3
answers82
viewsProblems with if doing 2 functions
I have to make a code where I calculate the BMI, but if the person is 15 years or less is not calculated, but is still calculating #include <stdio.h> void main() { float peso, altura, imc,…
-
0
votes4
answers11856
viewsHigher and lower value problem with while. (No list!)
Write a program that reads an integer N and then read N real numbers, separating the smallest and largest, presenting them on the screen. N = int(input("Digite N: ")) i = 0 ma = 'maior' me = 'menor'…