Posts by Bacco • 93,720 points
1,184 posts
-
3
votes1
answer16660
viewsA: How do I send an email from an HTML site form?
Without using a language server side, the way it is: <form method="post" action="mailto:[email protected]"> But this is a somewhat problematic solution, as it depends on the user having…
-
3
votes2
answers1390
viewsA: What is the list command for files starting with "a" and ending with "v"?
ls | grep ^a.*v$ ls list the directory | the pipe sends out the ls to the grep grep filter input with a regular expression, and return to output by default ^ is the beginning of the line a is the…
-
5
votes3
answers945
viewsA: Problem with php query because of quotation marks
The ideal, as already mentioned by @rray, is to use Prepared statements. But if you’re gonna use string "", there is already a certain function for this. For example, using functions mysqli_:…
-
2
votes2
answers769
viewsA: Double quotes in the URL
I assume you came from this answer of another question of yours: /a/121814/ In the original post (properly corrected by @rodorgas) quotes were missing on value, and as a result, the quotation marks…
-
5
votes1
answer619
viewsA: Is it correct to create a variable within an if?
First of all, the if is not a good example, because you can "create" the variable only once, even outside: $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT) if( $id ): /* Código que usa o…
-
3
votes3
answers317
viewsA: How to delete whitespace around a given character?
The @Marcelodeandrade answer is the most appropriate way for the exact case of the problem (and already received my +1), but only to complement, follows a version with Regex harnessing its…
-
2
votes1
answer524
viewsA: Calculate pixels for columns in css
If the space is 10px, there is nothing to complicate, You can divide the 950px. 310px per column 10px margin See in "whole page mode": div { box-sizing: border-box; padding:0; margin:0; } .works {…
-
10
votes2
answers318
viewsA: Separate values from each array
A possible solution would be to see what are common, and extract from the rest: $a = [1,2,3,4,5]; $b = [2,4,6,7]; $common = array_intersect( $b, $a ); $diff1 = array_diff( $a, $common ); $diff2 =…
-
1
votes2
answers30
viewsA: Divergence between manual populated A Array and variable data
There are a lot of problems in what you’re doing. See the first case: $poligono = array( "-22.8919, -43.1272", "-22.8652, -43.0954" ); |_____valor 1______| |_____valor 2______| You are clearly…
-
4
votes3
answers553
viewsA: Nth-Child does not work
As the answers already explain the problem, see a possible solution, adding an auxiliary class with sequential numbering: .intro-frases .t1, .intro-frases .t4, .intro-frases .t7 { color: red;…
-
9
votes2
answers9189
viewsA: Return today’s date in C# in specific format
If you want two digits, you need to specify two digits: DateTime.Now.ToString("yyyy'-'MM'-'dd"); DateTime.Now.ToString("yyyy-MM-dd"); Watch out for the capital letters. m is minute, M is month. See…
-
4
votes3
answers1261
viewsA: How to make the background inside a div occupy the whole body
I still don’t understand what the difficulty is, but it follows a very simple example that already shows a header with full width and a full image background, no matter the page size: body, html {…
-
9
votes2
answers8580
viewsA: How to move files with PHP copy?
Move files is with rename, and not with copy: bool rename ( string $oldname , string $newname [, resource $context ] ) Note that in Windows, the rename only moves between different disks from…
-
7
votes2
answers536
viewsA: Make an HTML checklist
CSS solution Your solution is good, but only for an odd number of columns: box_parceiro:nth-child(odd) If the number is odd, it will be a perfect checker, as the last of the first line will…
-
3
votes3
answers896
viewsA: HREF pointing to a button
A href pure does not do what you want, but a label with for can help you. Remembering that you can leave the stylized label as you think best. See a demonstration: <label id="remoto"…
-
4
votes2
answers645
viewsA: Make calculations based on PHP or Mysql averages
To get a listing with averages multiplied by 15: SELECT AVG( consumo ) * 15 AS media_consumo FROM leitura GROUP BY FLOOR( ( id - 1 ) / 5 ) ORDER BY id See working on SQL Fiddle. Of curiosity, the…
-
7
votes2
answers2263
viewsA: How to make CSS reminders when passing mouse cursor?
To show a "floating" widget in the mouseover: .hm div {display:none;position:relative} .hm:hover div {display:block;position:absolute;top:0;margin-left:40px} /* daqui pra baixo é só estética para…
-
5
votes1
answer2451
viewsA: Href does not work
As you are using Bootstrap, I think this is the best way to make a button: <a href="http://google.pt" class="btn btn-default">Ver</a> But if you’re gonna use field research, you need…
-
3
votes2
answers38081
viewsA: Calculate vector size
This line is calculating the size correctly: int len = sizeof(vetor)/sizeof(int); Better would be int len = sizeof(vetor)/sizeof(vetor[0]); because, in case you change the type of vetor, will not be…
-
2
votes1
answer471
viewsA: Foreach - Pagination with images
Note: This reply was posted to a previous edition of the question. Follow a simple and didactic example of paging, to serve as an example: $imagens =…
-
6
votes3
answers3725
viewsA: Convert "Floating" to Decimal
This is easy to solve with basic math: 1.01010101 is the same as 101010101 / 100000000 (just count the houses after the comma) Binário Decimal 101010101 ÷ 314 ÷ 100000000 256 ────────────…
-
1
votes3
answers355
viewsA: Gmail displaying source host on recipient when using PHP mail()
According to own PHP documentation, you can use additional parameters for the Mailer of the system. If the system is based on sendmail, there is a parameter that can help, the -f: <?php mail($to,…
-
7
votes12
answers28737
viewsA: What are the ways to iterate an array in PHP (without foreach)?
Okay, just fuck with me, here’s my answer: print_r( $array ); This iterates and already shows on the screen at once, both keys and values. And best of all, it works on arrays multi-level ;) Okay,…
-
4
votes2
answers79
viewsA: Capture the image link contained in html
Just use the right index: print_r( $matches[1] ); See working on IDEONE. You used the index 0, that represents the whole captured set. The 1 henceforth represent the catch groups in parentheses,…
-
3
votes1
answer912
viewsA: Take the values of two inputs, perform the calculation and display a third input
Here’s a simple demonstration of how to do it in JS: var tQtd = document.getElementById( 'qtd' ); var tVlr = document.getElementById( 'vlr' ); var tTot = document.getElementById( 'tot' );…
-
2
votes1
answer79
viewsA: Error md5 offertoro
You can not do many tests with what was posted in the question, but one thing is certain: in PHP, it is not used + to concatenate strings. This line has problems: $secret = md5( $oid + "-" + $id +…
-
4
votes1
answer221
viewsA: Error converting mysql_list_tables to mysqli_
You can’t mix library functions mysql and mysqli. It turns out that the library mysqli does not have a function directly equivalent to mysql_list_tables, but it is easy to get the listing using a…
-
6
votes2
answers1261
viewsA: Do not insert zeros to the left of a number
Follow an example using setInterval. It was done this way to work directly on the value, regardless of the way the data was entered. Test here: var l = document.getElementsByClassName( 'zeros' );…
javascriptanswered Bacco 93,720 -
2
votes1
answer358
viewsA: What’s the relationship between Oauth and Rest?
Rest has no direct relationship with Oauth, the first is an information exchange architecture, and the second is an authorization mechanism (actually, ends up being confused with authentication, but…
-
2
votes4
answers158
viewsA: Passing argument by PHP array
For the record, a variant of the @rray response: $a = array( array( '1', '2', '2016' ), array( '2', '2', '2016' ), array( '3', '2', '2016' ) ); foreach($a as $as){ exec( $as[0], $as[1], $as[2] ); }…
-
6
votes1
answer245
viewsA: I cannot limit text with Japanese characters
Functions of string You are using the wrong function. The function substr is for use with 1 encodings byte by character, as ISO-8859-1. The functions to multibyte has the prefix mb_. Right: echo…
-
4
votes1
answer38
viewsA: Stylesheet with cookie works only the second time
This line of yours has a problem: $estilo_cor = setcookie('cor_estilo', 'padrao', (time() + (2 * 3600))); She won’t take the value of cookie set, only one true or false. See a solution that assigns…
-
2
votes1
answer72
viewsA: Search by word taking into account the relationship between 3 tables
You can put all the conditions on WHERE: SELECT empresa.nome, categoria.nome FROM categoria_empresa INNER JOIN categoria ON categoria.id_categoria = categoria_empresa.id_categoria INNER JOIN empresa…
-
4
votes1
answer23
viewsA: Show occurrences as fields
Basically that’s it: SELECT SUM( IF( status='pendente' , 1, 0 ) ) AS pendente, SUM( IF( status='concluida', 1, 0 ) ) AS concluida FROM tarefas See working on SQL Fiddle…
-
6
votes2
answers98
viewsA: Return ID of who has the shortest distance between coordinates
The min.apply will not help you in this case because it returns only one value. You would have to create a structure with distância, id, and return both. See a functional example: (I wiped the code…
-
3
votes2
answers998
viewsA: Script open only after given time
One solution is to dynamically add JS to the page. Click "Run" below, and see a functional demonstration of this code: var delayedScript =document.createElement('script');…
-
3
votes2
answers1709
viewsA: Recording variables in the database and how to retrieve them and assign value
Since you didn’t mention where the variables come from, I’ll give you a general example of a system of templates: Information from the DB: <html> Nome: $nome$ </html> PHP <?php…
-
3
votes2
answers88
viewsA: How to update the last name of a person who starts with the initial 'Fabio%'?
It follows an alternative that only changes the "Mello": UPDATE pessoa SET nome = REPLACE(nome, 'Mello', 'Borges' ) WHERE nome LIKE 'Fabio' Note that I’m just demonstrating the REPLACE. I stop the…
-
4
votes1
answer2495
viewsA: Function reverses numbers in array
I’ll take this data as an example: vetor = 71,72,73,74,75,76,77 n = 7 (que é o tamanho de "vetor") Thus the loop will cause i go from 0 and stop when you arrive at 7/2, that is 3 (how it was used i…
-
2
votes1
answer75
viewsA: Split monetary value by checked box
Following a simplification in the code: function calcula() { var total = $('#total').val(); var qtd = $('input[type=checkbox]:checked').length; $('#resultado').html( total / qtd ); }…
-
5
votes2
answers268
viewsA: How to remove R$ from Numberformatter?
When you use NumberFormatter::CURRENCY, is asking for the "complete package", which includes currency and thousand and decimal separators. An option for the numeric part is to use…
-
13
votes2
answers4940
viewsA: What’s the difference between Sessions and Cookies
Cookies In a very simplified way, cookies are small data that is sent by the Web server to a client, so that this client returns the same data in the next (s) request(s)). When to use? Basically…
-
2
votes1
answer44
viewsA: XML repeats record when generated in PHP
You are adding the content repeatedly to the file. See the difference within the WHILE: $arquivo = "nuroa.xml"; $ponteiro = fopen($arquivo, "w"); fwrite($ponteiro, "<?xml version='1.0'…
-
3
votes2
answers105
viewsA: For rule in C
To better understand, follow your code with some instructions for debug: int x; int y; for( x=2, y=1; x<11; x++ ) { printf("antes x = %d, y= %d \n", x, y ); y += x++; printf("depois x = %d, y= %d…
-
3
votes4
answers1750
viewsA: How to create a list of dates of the year in php, skipping the weekends?
We already have several answers, but there goes another way, in "compact version": $year = 2016; for( $d = mktime( 0, 0, 0, 1, 1, $year ); date( 'Y', $d ) == $year; $d += 86400 ) date( 'N', $d )…
-
2
votes1
answer485
viewsA: How do I make Transition work in "round trip" when using Hover?
Put the transition in the original object, and not in :hover: .novidades{ display:block; height:100px; width:200px; /* só pra demonstrar */ background-color: #f5dcdc; position: relative; bottom: 0;…
-
2
votes1
answer803
viewsA: Start/End of Summer Time: problem with date verification of type "greater than"
Just use GMT instead of local time: $dataProxima = gmdate('Y-m-d H:i:s' ... According to the documentation: gmdate - Format a GMT/CUT date/time Identical to date() function except that the time is…
-
2
votes2
answers133
viewsA: CSS Animate does not stop at last keyframe
One output is to specify how many times the animation will occur: animation-iteration-count: 1 In operation: * {position:relative} div {width:100px;height:100px;background:#ff9} .mostramenu {…
-
4
votes3
answers394
viewsA: Data Range Search in SQL
Basically this: SELECT DATE_FORMAT( data_venda, '%d-%m-%Y') AS datavenda FROM venda WHERE data_venda BETWEEN '2016-01-18' AND '2016-02-15' To use more fields: SELECT campo1, campo2, DATE_FORMAT(…
-
15
votes2
answers10563
viewsA: Format/mask CPF in Mysql or PDO
Using the function INSERT To add characters to a result, you can use the function INSERT. Not to be confused with the syntax INSERT INTO, we are talking about the function of string. SELECT INSERT(…