Posts by Bacco • 93,720 points
1,184 posts
-
6
votes2
answers283
viewsA: Count numbers drawn on a lottery table
Since this is a draw where there is no repetition of values in the columns, you can use the operator IN: SELECT COUNT(*) FROM sorteiosanteriores WHERE 20 IN (bola1,bola2,bola3,bola4,bola5,bola6 ...…
-
2
votes1
answer142
viewsA: In Mysql group by week does not list correctly
If you want to join just for the week, Monday through Friday, this is probably a better way: SELECT COUNT(id_usuario) AS total, dia FROM acesso GROUP BY FLOOR(TO_DAYS(dia)/7) ORDER BY dia If you…
-
0
votes1
answer127
viewsA: Extract of hours online per day
answer prepared by the author of the question, transcribed here After reading the Mysql documentation sent by @ngueno, I was able to arrive at the expected result by modifying my Query and treating…
-
5
votes1
answer20
viewsA: Why is my getbands returning 'L'?
L is "Level", a grey channel only. This sort of thing is merely a matter of studying the library manual used, probably the PIL/Pillow in the case. Modes (which therefore define the most common…
python-3.xanswered Bacco 93,720 -
6
votes1
answer77
viewsA: How can I create a json decision
What you need in your case is the application of a if conventional using Javascript itself. First of all, some adjustments made to your code (modifying some parts purposely so you see more…
-
9
votes2
answers1607
viewsA: Count the number of characters in a String?
Basic error of type. If you want to resume a number in the function, it’s public int or public Integer and not public String public Integer contarLetras(String texto) { return texto.length(); } In…
-
3
votes1
answer71
viewsA: How to order query in MYSQL by relevance? (first results that the term is in the title, then in the content)
Basic case of use of ORDER BY ... sua query ... ORDER BY titulo LIKE "%batata%" DESC, ingredientes LIKE "%batata%" DESC, nota DESC This works simply because the LIKE return bool (zero or one), and…
-
4
votes1
answer137
viewsA: Convert a char array to an ints array
The value -38 already gives a good indication of the problem. On this line here you make the characters of '0' to '9' are converted into a number from zero to nine: tmp = s - '0' ; It’s just that…
-
9
votes3
answers820
viewsA: How to exit the FOR loop within the Switch structure?
These are two sketches that may or may not be applicable to your code, but I’ve come up with an alternative to what has already been posted. You have to scan the rest of the code to see which option…
-
1
votes1
answer294
viewsA: How to list and delete Variables in Mysql?
Basically eliminates like this: SET @var = NULL; you will simply be reverting the variable to the original situation (whole SELECT @variavelnaoexistente gives NULL). The important thing is to know…
-
25
votes2
answers153
viewsA: Why can’t I call methods directly in a Javascript number?
Yes! The problem is just the syntax of your test. Notice that with just a small adjustment it already works: console.log( (2).toString() ); What happens is that the interpreter will not understand…
javascriptanswered Bacco 93,720 -
2
votes1
answer45
viewsA: Toggle Variable within While
All the examples here are on IDEONE. There are several ways. See some: Alternating with subtraction $alterna = 1; while ( ... ) { $alterna = 1 - $alterna; // Ou vai ser 1-0, ou 1-1 sempre if…
-
2
votes3
answers298
viewsA: Function . play() in jQuery
Basically, to do this: $('#aud1') will not bring an element that has the method .play() (did not find this method in jQuery documentation, can not confuse the object of jQuery with that of DOM). If…
-
5
votes1
answer76
viewsA: PHP: Return previous value of the "for" loop variable
Just do $var3 = $var2 BEFORE THE $var2 = formula $max = 10; $var2 = 0; for($i = 0; $i <= $max; $i++){ $var3 = $var2; // Neste momento o $var2 ainda não pegou a linha atual // consequentemente,…
-
2
votes1
answer138
viewsA: How to add count with PHP?
According to the documentation on https://developer.wordpress.org/reference/classes/wp_query/ Wordpress itself already has a specific property to know the content of the current post: <slide…
-
3
votes1
answer3140
viewsA: How to change data types in fields in a table in mysql at once
Yes, there is. The SQL standard defines a change only each ALTER TABLE, but Mysql extended the default to allow this syntax: ALTER TABLE PESSOAS MODIFY nome VARCHAR(20) NOT NULL, peso DECIMAL(5,3),…
-
4
votes2
answers94
viewsA: How does the reader know which table of my comic will be used for my operation?
I took it on the basis of Documentation official, but I added some notes: Table names Note that we did not say what was the name of the model’s table Flight. By convention, the plural of the class…
-
14
votes1
answer112
viewsA: Because list does not accept [01,02,03,04]
"It is wrong because it is wrong" :D Python 2 In Python 2, your syntax would be wrong, as numbers prefixed by 0 would be octal, and there would be no octal 08 (valid octal digits are 0 to 7). Also,…
-
1
votes1
answer146
viewsA: ORDER BY in php with paging ordering only the first page
Nor would it be otherwise, after all you are only passing the page number, you are not passing the filter or ordering: echo "<li><a href=\"?pagina=$i\">$i</a></li>"; You’d…
-
9
votes2
answers240
viewsA: How to make a sequence of boxes with the triangular border on the right, on top of the other, box with CSS?
One of the traditional ways is to use "border Triangle": .breadcrumb { display:inline-block; position:relative; line-height:30px; /* altura final da linha */ text-align:center; padding-right:20px;…
-
9
votes2
answers897
viewsA: Is there an Excel function that associates letters with numbers (A = 1, B = 2, C = 3 etc.)?
You can use: CÓDIGO("A") - 64 In the English version: CODE("A") - 64 As the ASCII code of A is 65, it will return 1, B will return 2, so successively. Just be careful with lower case letters,…
-
5
votes2
answers50
viewsA: Travel consultation
Basically this: SELECT l.id FROM (SELECT id FROM movimentacao WHERE movimento = 'embalado' ) l LEFT JOIN (SELECT id FROM movimentacao WHERE movimento = 'despachado') r USING(id) WHERE r.id IS NULL…
-
2
votes2
answers301
viewsA: Doubt to use Replace together with Inner Join
Does not change the JOIN in the question, can apply replace normally: SELECT REPLACE( eventos.colab_id, '"', '') AS colabid, colaboradores.setor FROM colaboradores INNER JOIN eventos ON…
-
6
votes1
answer1358
viewsA: Error in PHP ... Fatal error: Uncaught Error: Call to a Member Function Modify() on Boolean
Basically you passed an invalid value to the function and did not test. Ideally your code would have something like this: $dt_mod1 = DateTime::createFromFormat('d/m/Y H:i:s', $dt_mod); if ( $dt_mod1…
-
4
votes1
answer891
viewsA: Autocomplete with data coming from PHP
The problem is that line breaks are generating a Javascript error. The solution is to clear these special characters in the echo: <?php $query_clientes = 'SELECT nome FROM clientes';…
-
4
votes1
answer290
viewsA: Cannot pass Parameter 2 by Reference using PDO like
The bindParam() receives the parameters by reference, so you can not use literals, only variables. Using variable, it looks like this: $variavel = '%'.$this->inputSearchProtocol.'%';…
-
3
votes1
answer165
viewsA: How to know the direction of the mouse?
You have to compare with the previous position, not twice with the same. Something like that: import pynput def Position(): mouse = pynput.mouse.Controller() position_anterior = mouse.position[0]…
-
11
votes2
answers687
viewsA: How to make an Animation in CSS with drag effect. Place Blur in motion
The "fastest" way to adapt your code is by adding a "shadow backwards". The colors are a gradient between the front and the bottom: 27% {box-shadow:-10px 0 0 #999,-20px 0 0 #777,-30px 0 0 #666,-40px…
-
3
votes1
answer359
viewsA: How do I not repeat RAND() results in php?
The ORDER BY RAND() by itself does not repeat any data. It just varies the output order. Apparently the solution to your case is to take the query loop, because the problem is that you do several…
-
2
votes1
answer126
viewsA: Mysql - update via db with "set price = price - 5%"
Five percent = 5 / 100 therefore: preco = preco - ( preco * 5 / 100 )
-
5
votes2
answers224
viewsA: Condition for INSERT INTO
Basically this: INSERT INTO tabela SET coluna = IF( @variavel IN (1,2,3), 1, 0 ); The IN returns true if the variable is in the list The IF returns the second value if the first expression is true,…
-
7
votes2
answers388
viewsA: Directory listing appears with dots, how to remove?
It’s not a bug, that’s the way it is. Every directory has an entry . representing the current level and .. representing the previous: If you don’t want to show these entries, just by a condition…
-
7
votes3
answers3255
viewsA: Wrong daylight saving time
If the problem is in the OS Under Linux you need to do an update, which will probably bring the correct TZDATA (Apache takes OS). If you are going to manually correct, you have to see where your…
-
4
votes1
answer179
viewsA: CONCAT is not working when column is NULL
Use the COALESCE: UPDATE propostas SET obs = CONCAT( COALESCE(obs,""), 'aaa'), cd_status = 0 WHERE tsk_id = 1 The COALESCE receives a list of values, and returns the first non-null of it. In this…
-
1
votes1
answer14
viewsA: Manipulation and grid, hbox and Vbox in pyqt4
Here is a simple example of how to use two columns with Qgridlayout: self.botao_enviar = qg.QPushButton('ENVIAR') self.botao_salvar = qg.QPushButton('SALVAR') self.botao_restaurar =…
-
3
votes1
answer94
viewsA: How to emulate ROW_NUMBER() in Mysql V5.7?
Basically with variables: SET @linha := 0; SELECT campo1, campo2, @linha := @linha + 1 AS row_number FROM tabela; If for some reason you cannot run the separate SET, you can do so: SELECT campo1,…
-
1
votes1
answer29
viewsA: Add a fixed image sequence in PHP
Has many ways. Here we create a array with 3 names: $img[1] = 'ouro.jpg'; $img[2] = 'prata.jpg'; $img[3] = 'bronze.jpg'; And a if inline (ternary parole): ( $pos<4 ? '<img…
-
4
votes1
answer38
viewsA: How to make an IF read two category types at the same time?
Thus: if ($this->GetCategoryName() == 'mmorpg' && $this->GetCategoryName() == 'shots') { But there’s a logic error, if it’s one thing it’s another. In PHP you can use && for…
-
5
votes2
answers254
viewsA: Mysql doubt compare multiple columns
tl;dr This is a case that is solved well with JOIN, after all all all tables have a very regular structure, and a very direct relationship: SELECT nome, COUNT(*) AS atendidas, SUM(pontuacao.valor -…
-
7
votes1
answer627
viewsA: How to adjust Background to fit inside container without cutting anything?
Option round of property background-repeat: The option round makes a minimal distortion on the background image so that it fits as well as possible to not cut the image. div { background-image:…
-
4
votes1
answer208
viewsA: Ending the PHP script with "Exit" would delete all variables and destroy objects?
YES. Is in the manual: http://php.net/manual/en/function.exit.php (for a change, in Portuguese missing important pieces in the translation) Exit - Output a message and terminate the Current script…
-
2
votes1
answer118
viewsA: Select for a specific period in Mysql
One possibility is to do 2 operations: WHERE Data = DATE_SUB(DATE_SUB(CURRENT_DATE, INTERVAL 2 MONTH), INTERVAL 5 DAY) Other: WHERE Data = CURRENT_DATE + INTERVAL - 2 MONTH + INTERVAL - 5 DAY; See…
-
4
votes2
answers375
views -
3
votes1
answer230
viewsA: Laravel Mail, Error: Undefined variable
The problem: In AgendamentoEpcSup.php, in the __construct() you do: $this->schedule = $schedule ...but did not set $Schedule anywhere, the error is only stating the obvious. How did the…
-
3
votes1
answer524
views -
1
votes1
answer34
viewsA: Select with Join alternative MYSQL
On the part of SELECT, to get the name: COALESCE(administrator.name, users.first_name) AS nome Or, you can use an IF: IF(log_tables_restaurants.id_admin IS NULL, users.first_name,…
-
9
votes2
answers1974
viewsA: How to check if an id exists?
There is no function getElementeByid in Javascript. it’s not "Elemente," it’s "Element" and "Id" is capitalized. Correct function: getElementById. And you don’t have to call the function twice, you…
javascriptanswered Bacco 93,720 -
7
votes1
answer85
viewsA: Doing BMI calculations I’m not getting just the result 80
In the first test it was not possible to reproduce its problem: https://ideone.com/m4IVad The second is basic math error. First you divide weight by height, then you multiply by height:…
-
4
votes3
answers596
viewsA: Questions about the Count sql command
The count(expressao) doesn’t fit what you’re trying to. It returns does not count "true" or "false", but "how many occurrences of expressão are not null. The count(*) is an exception, it returns all…
-
7
votes1
answer226
viewsA: Exchange %20 for + in GET search
Both the %20 as to the + are valid characters to represent the space, being the first used in Urls and the second in Forms, by default (for example, in querystring). The + was specified in this RFC:…