Posts by bfavaretto • 64,705 points
902 posts
-
4
votes3
answers329
viewsA: How to pass Id next to pagination ex: index? pag=pagina&ID?
Parameters passed by GET must be in format chave=valor. So you can do something like this: index.php?secao=estudos&pagina=1 (Adjust parameter names as needed.)…
-
1
votes2
answers38
viewsA: Can I have different Transitions on the same tag?
The way you did, the transition from height simply override that of opacity. You need to list all properties that will transition at once, separated by commas, like this: .trans { background: #F00;…
-
4
votes2
answers581
viewsA: How to create a link that when clicked changes the value of href=""?
There are several ways to do this. I would avoid inline Javascript (within href or other attribute). Something like this would be cleaner: <a id="botao-chat" href="#">ABRIR CHAT</a>…
jqueryanswered bfavaretto 64,705 -
1
votes1
answer2672
viewsA: Mysql Error 1049 How to Solve
To option -r refers to how certain special characters should be escaped in the client output. In your command, root is being interpreted as the name of the database you want to access. I believe you…
-
3
votes2
answers1373
viewsA: How to make a select with dynamic columns for each like?
If you accept that each carrier comes in a row, and not in a column, you can just do so: SELECT calldate AS Data, dstchannel AS Operadora, COUNT(*) AS Quantiade FROM cdr WHERE dstchannel REGEXP…
mysqlanswered bfavaretto 64,705 -
6
votes3
answers2946
viewsA: Doubt with Javascript Replace
It is possible with regular expression. I am not a master in the subject, but this seems to give an account: var re = /^(\d+),(\d+) %$/; console.log("0,0000 %".replace(re, "$1.$2")); The above…
javascriptanswered bfavaretto 64,705 -
3
votes1
answer580
viewsA: Tender relationship with a foreign key not mandatory
The structure of the database seems to me perfectly adequate, I would probably do likewise. The consultation is not so complicated. You will need a JOIN for each of the related tables. As it is…
-
1
votes1
answer353
viewsA: Google Maps API - window always opens the last
The problem is there at the end, at the event: google.maps.event.addListener(Marker, "click", function() { infoLocal.open(map,Marker); }); It happens that at the moment of the click, Marker is no…
-
5
votes2
answers155
viewsA: How to check WHERE clause with apostrophe in a DELETE operation?
If you use two apostrophes ('') should solve it. But I believe that you really should be parameterizing your query, and that character would be no problem.…
-
9
votes2
answers6234
viewsA: How to check if a number is decimal?
If I understand correctly, you want a function that returns false for integers and non-numerical values, and true for broken numbers. Something like that should work: function isDecimal(num) {…
javascriptanswered bfavaretto 64,705 -
4
votes3
answers71
viewsA: Wrapping part of a string
You cannot concatenate a string into a literal regular expression as you are trying (in fact, you ended up using a string instead of the literal regex). Use the builder RegExp: var foo =…
-
1
votes3
answers525
viewsA: Doubt with Mysqli and PHP OO
You can set default values for parameters you don’t want to always pass: public function registerUser($link, $nome, $sobrenome=null, $apelido=null) { } Note: as you are using mysqli, strongly…
-
2
votes2
answers87
viewsA: Javascript Array php values
Mount the array in php first, then output it with: echo json_encode($minhaArray); The result will be: [[38.951399, -76.958463], [38.942855, -76.959149]]…
-
4
votes2
answers2364
viewsA: About Object Oriented in PHP
You can pass the connection only once, at the instantiation of the class, and store it on a property. Something like this: // Nomes de classe costumam ter iniciais maiúsculas class Autenticacao { //…
-
5
votes1
answer1007
viewsA: Pass Javascript variable to PHP body
If it is possible to bring the name of the driver in the same query, I would put it inside a data attribute: while ($row = $result->fetch_assoc()) { unset($idTransportador, $Nome_Uso);…
-
4
votes3
answers118
viewsA: Is it dangerous to use for loop in querySelectorAll?
If you need to do something with all elements that match a given selector, the only way is to loop over the list of these elements (be it obtained with the querySelectorAll or by some other method,…
javascriptanswered bfavaretto 64,705 -
2
votes1
answer766
viewsA: Canvas is not showing the image with drawImage()
Since your script is included after the canvas, you don’t even have to wait for the load of window to draw. But you have to wait load of the image: var canvas = document.getElementById("canvasBg");…
-
1
votes2
answers3265
viewsA: Ajax date return behavior
Your Javascript/jQuery code makes an HTTP request to the server. PHP receives, handles, and responds to this request. The two languages (Javascript and PHP) do not talk directly, only via requests…
-
13
votes3
answers8116
viewsA: How does the session work in web browsers?
Sessions usually depend on cookies, but the data is stored on the server. It works like this: A session is started on the server, which sends a cookie to the browser with a unique ID of that…
-
1
votes2
answers333
viewsA: Query using Mongoose in Nodejs always returns null even within asynchronous method
Create the object with the parameters first, and use the bracket notation to have a dynamic key: function isAuthorized(sessionID, sessionIDtype, callback){ var parametros = {};…
-
5
votes5
answers23429
viewsA: Calling js function in another file - Dependency between Javascript scripts
By what you’re saying, if the files are being loaded in the correct order - i.e., what contains the function statement exibirModal being loaded before you try to call this function -, all indicates…
javascriptanswered bfavaretto 64,705 -
5
votes2
answers588
viewsA: Web Components - What is the difference between Polymer and Reactjs?
As I have never used any of the two libraries, I reply with what I understand to be the basic difference between them: while Polymer is an attempt to give immediate support to the new W3C…
-
1
votes2
answers578
viewsA: Slim routing does not work
Your htaccess rewrites the URL without passing any parameters. Try this: RewriteRule ^(.*)$ /index.php?$1 [QSA]
slimanswered bfavaretto 64,705 -
4
votes3
answers279
viewsA: How to test whether an instance is dynamic or static?
As far as I know, it is not possible to return reference to a PHP class without using Reflection. So, the scenario in which something would return \Acme\Foo, and not an instance, would depend on…
phpanswered bfavaretto 64,705 -
5
votes3
answers614
viewsA: jQuery’s$ doesn’t work
Wakim is right, there is probably another code (probably another framework) using $. But what you may not know is that jQuery passes the object itself jQuery as an argument from callback of ready.…
jqueryanswered bfavaretto 64,705 -
6
votes1
answer73
viewsA: Is there any difference between an event with passing parameters to one without passing?
Both will be triggered. The passage of the parameters is determined by who issues the event, not by their appointment in the listeners. Therefore the first parameter (event object) is always passed…
jqueryanswered bfavaretto 64,705 -
17
votes6
answers2856
viewsA: Can not use "{ }" IF keys in PHP cause problems?
This is a controversial debate in several languages, not just PHP. There is no correct answer. Ultimately it is a matter of style and will not generate problems if all necessary care is taken. Many…
-
4
votes1
answer520
viewsA: How to access an element (or its values) generated dynamically?
It seems that you are confused about the need for delegation. When you select an element with jQuery - for example, with $('#algumId') –the element is selected only if it exists. If it doesn’t…
jqueryanswered bfavaretto 64,705 -
4
votes1
answer524
viewsA: setInterval javascript does not work
You need to change the rotation within of callback of setInterval: function girar(){ var bola = document.getElementById("ball"); window.xvel = 10; setInterval(function(){ window.xvel =…
-
2
votes2
answers2474
viewsA: Get values from within a function that is within another function
It will not work that way, because the operation of collecting the data is asynchronous. It is only completed afterward that the function pegaVariavel returns. What you can do is pass a callback to…
-
4
votes2
answers1596
viewsA: Foreach is returning only one record
As Bacco says, you cannot have more than one key with the same name in an array. But you can call its function several times: $Habeo->DuplicateRegister('contatos', array('id'=>'1'));…
-
2
votes1
answer157
viewsA: Database query refactoring with multiples FIND_IN_SET()
It would be interesting to normalize the bank, creating a relationship table between press and tags. The column press.tag_id would be eliminated, and the relationship table press_tags would look…
-
5
votes6
answers1555
viewsA: How to do the following query without using INNER JOIN?
Yes, just use it aliases different for the table in each JOIN: SELECT Envios.*, PaisEnvio.nome_pais AS nome_pais_envio, PaisRecibo.nome_pais AS nome_pais_recibo FROM Envios INNER JOIN Paises AS…
-
1
votes2
answers956
viewsA: PHP version without phpinfo() or phpversion()
Per command line: php.exe --version But beware: if you have more than one php version on the machine, the command line executable can be from one, and the one that runs on the webserver, from…
-
8
votes3
answers3726
viewsA: What good is a "self Join"?
Trees can be represented in a single table. For example: eletrônicos áudio e vídeo TVs HD Full HD 4k Home Theaters ... informática ... ... Table-shaped: id parent_id nome…
-
4
votes2
answers74
viewsA: td in a Function
One possibility is to save this HTML as a template within a tag <script>. The type="text/template" makes the content not be interpreted as JS: <script id="template-celula"…
javascriptanswered bfavaretto 64,705 -
4
votes1
answer149
viewsA: Undefined variable: QUERY_STRING & PHP_SELF in
These variables are not declared in the script you posted, and by the error are also not in the ad_inc.php that is being included. It seems that the script depends on the register_globals activated…
phpanswered bfavaretto 64,705 -
7
votes9
answers166445
viewsA: How to hide/show a div in HTML?
If you want a function that shows when it is hidden, and hides when it is visible (i.e., a toggle), do so: function toggleEstado(divid) { var div = document.getElementById(divid); var disp =…
-
10
votes1
answer391
viewsA: Interruption of an asynchronous request
What happens when the user, for example, reloads the page with an asynchronous request in progress? Depends on the timing. If the request has already been sent to the server, it is processed…
-
3
votes1
answer861
viewsA: Pass values to PHP file with JSON
Over there where you’re passing null, pass an object: $.getJSON(urlTeste, {chave: "valor", outro: "outro valor"}, function(data){ $('#resultado').html(data); }); And in PHP: <?php $chave =…
-
5
votes2
answers133
viewsA: When using div+selector in CSS
I see two reasons why: You use the class seletor in more than one element type, and want to create a CSS rule for Divs only. You need to give more weight to this rule in the CSS cascade. For…
-
3
votes1
answer2870
viewsA: How to select a radio when clicking on the text next to it?
Just put the text inside an element <label> pointing to the ID of the input correspondent: <input type="radio" name="cores" id="vermelho"><label…
-
2
votes1
answer61
viewsA: In Cakephp, why does the input method generate an empty selector?
It has a convention: if there exists in the view a variable with the plural name of the related model, it fills the dropdown options by itself. For example, put this in the controller, in…
-
2
votes1
answer356
viewsA: div.childNodes.item(0) recognizes tab or space as child
The nodes of the GIFT can be of several guys, including text nodes, which is what you are finding. You can create a function to find the first node of type ELEMENT_NODE. Something like that:…
-
3
votes5
answers6102
viewsA: How to create a view in mysql by taking data from 3 tables and repeating the different columns in the result?
All other answers assume that in the 3 tables each person always has the same ID. This is true in the example posted, but I’m not so sure it is so in the actual database. So I also suggest a LEFT…
-
7
votes2
answers1589
viewsA: Generate single color for each result
Considering an array of colors like this: $cores = array('#000', '#333', '#666', '#999'); // do tamanho que você precisar I would create a second array, associative, where you save colors for each…
-
18
votes2
answers146605
viewsA: How to get input using HTML and Javascript
In this simple example, it is possible to solve by treating only the event submit of the form itself: <form id="formulario"> <input type="text" id="campo"> <input type="submit"…
-
3
votes1
answer1477
viewsA: How to import Firebird data to mysql?
The answer below had originally been posted as a question by the author of the question. Now set as a Community Wiki to register. A while ago I had the need to import the data from a table of…
-
4
votes2
answers1628
viewsA: Comparing string in php
PHP already has a function ready to count substring occurrences in a string, substr_count. With this, the loop line by line is not even necessary. The use is like this: $texto = "um texto grande ...…
phpanswered bfavaretto 64,705 -
2
votes1
answer1544
viewsA: Can I use ANSI charset in HTML files?
You are confused, UTF-8 has nothing to do with "HTML entities" like é. UTF-8 is a way to represent the characters in bytes, as well as ANSI (Windows-1252, similar to ISO-8859-1, or Latin…