Posts by Ivan Ferrer • 12,096 points
772 posts
-
0
votes3
answers44
viewsA: How to order from what has more records to what has less
In SQL, for you to bring these "some products", first you need to define how many will be, in the example below I considered the top 10: SELECT prd.id_produto, rel.ip COUNT(prd.id_produto) AS…
-
0
votes2
answers81
viewsA: How to delete the first line of a megaheavy SQL file?
For the record, the way I did it was by getting into the terminal, and typing: vi arquivo_megapesado.sql Inside the editor vi, typed: i, in order to edit the file, I deleted the piece I wanted, then…
-
2
votes2
answers81
viewsQ: How to delete the first line of a megaheavy SQL file?
I have a "mega heavy" SQL file that doesn’t open in the sublime, nor in the notepad nor in gedit. I just need to delete the first line Use nome_database; to be able to import via the mysql Workbench…
-
2
votes2
answers284
viewsA: How to keep a $_POST on the page
In this case, to not present the error, you can make a check on $_POST and save to page session perguntas.php: session_start(); $sub_grupo = null; if (isset($_POST['sub_grupo'])) { $sub_grupo =…
-
1
votes4
answers8025
viewsA: Searching dates through BETWEEN AND
To solve the problem, there are two ways to do using BETWEEN, when using datetime: SELECT * FROM sales.logger where DATE_FORMAT(data, '%Y-%m-%d') BETWEEN '2016-04-12' AND '2016-04-14' ORDER BY data;…
mysqlanswered Ivan Ferrer 12,096 -
1
votes3
answers1589
viewsA: Insert data into a multidimensional array
To do this in a multidimensional array, being the dynamic keys, it is important to know which key you want to update, I put an array example that takes the whole matrix structure and updates the…
-
1
votes2
answers703
viewsA: show angular variable in iframe
You cannot concatenate the URL within the source attribute for security reasons: you must concatenate the Javascript URL into a scope for example a urlVideo variable and then ng-src = {{urlVideo}} .…
-
5
votes3
answers1322
viewsA: Add "name" to a JSON object
To do this, simply add the keys: $aluno = array(); while($row = mysqli_fetch_array($verifica)) { $aluno[]= $row['username']; } $alunoToledo = array(); while($lista2 = mysqli_fetch_array($verifica2))…
-
0
votes3
answers47
viewsA: Second button replacing contents of the first
I believe that if you do this way will solve your problem, I have not tested, but if it does not work, try to put delegate for each of the eventClick: $(function() { $("#matriz, #saopaulo").hide();…
-
1
votes3
answers910
viewsA: Close the Bootstrap dropdown by clicking on another dropdown in the same menu?
Already solved the problem, just make a Trigger on the button: $(function() { $('.dropdown.opened') .on({ "shown.bs.dropdown": function() { this.closable = ($('.dropdown.open').length > 1) ? true…
-
2
votes1
answer845
viewsA: PHP Mailer sending email without the information
The solution to your problem would be basically this: require 'mailer/PHPMailerAutoload.php'; class SendMail extends Exception { private $params; private $identificador; private $nome; private…
-
4
votes3
answers910
viewsQ: Close the Bootstrap dropdown by clicking on another dropdown in the same menu?
The menu needs to remain open while I click anywhere on the document or screen, however, when I click on the dropdown of a second menu, it should close the previous one, and also need to open and…
-
1
votes5
answers946
viewsA: Bootstrap: prevent the menu from closing when clicked out of it
Sorry, I understand what you wanted, try doing this: I edited the question, see if it fits your purpose: $(function() { $('.dropdown.opened') .on({ "shown.bs.dropdown": function() { this.closable =…
-
1
votes3
answers112
viewsA: INSERT method with PHP OO error using SQL SERVER 2012
Your code needs some observations: 1) When registering something in the database, it is recommended to keep a key auto_increment, this way there is no need to increment the author id. 2) When you…
-
0
votes3
answers1437
viewsA: Find higher sum value and show id
I think it works that way, since it’s to catch the biggest: SELECT TOP 1 total.horas_totais, total.rg, total.num_projeto FROM ( SELECT DISTINCT NUM_PROJETO as num_projeto, SUM(HORAS) AS…
-
2
votes1
answer760
viewsA: Data formatting
Try to use the DATE_FORMAT(campo, 'formato') mysql, and use the static method DB::raw() (raw sql), to allow formatting: $query = DB::table('empenho as emp')…
laravelanswered Ivan Ferrer 12,096 -
4
votes3
answers1826
viewsA: Why use getElementById if id is in the window?
The difference is small, it is more in the processing time. "Document" is already an element rendered by Dom, in this sense, when you use getElementById you are capturing the rendered element id…
-
4
votes1
answer58
viewsQ: Is the window rendered by the gift or does it come before that?
A curiosity: I wonder if the window is rendered by dom when loading the window, as the document is usually window.document.html. Or the dom comes after this parameter?…
-
0
votes3
answers141
viewsA: Organize object in Javascript
Just take the first structure of the array: var armazenado = objTeste[0]; And to use this structure: var id = armazenado.id; var nome = armazenado.nome; var id_pai = armazenado.pai.id; var nome_pai…
javascriptanswered Ivan Ferrer 12,096 -
0
votes2
answers129
viewsA: Operation with Java Factorials
That would be about it: public static int Fatorial(int num) { if (num != 1) { num *= Fatorial(num - 1); } return num; }
javaanswered Ivan Ferrer 12,096 -
6
votes1
answer243
viewsQ: Why does 'window.Alert()' work in tabbed navigation and 'window.Focus()' does not?
I have the following method: (function(){ window.addEventListener('blur', openChat); window.addEventListener('pagehide', openChat); })(); function openChat(){ setTimeout(function(){ alert('Há uma…
-
0
votes2
answers183
viewsA: Error in PHP Paging
This is one way to make it work: class Paginacao { private $limit=3; private $proxima='<b>Próxima »</b>'; private $anterior='<b>«…
-
1
votes4
answers1407
viewsA: How to make elements appear and disappear with Js
A simple way to do this is like this: <div id="el"> <h1>TEXTO DE EXEMPLO 1</h1> <h1>TEXTO DE EXEMPLO 2</h1> <h1>TEXTO DE EXEMPLO 3</h1> </div> Script:…
-
0
votes2
answers56
viewsA: Best way to capture data from a query
There is no best way, what exists is the way that most meets your purpose, in the case below, is a simple example, using PDO: class Database { private static $servidor = 'localhost'; // Servidor, no…
-
-1
votes1
answer547
viewsA: can run a query within a user defined function in php?
To make a encapsulation, I prefer to use PDO: class Database { private static $servidor = 'localhost'; // Servidor, no caso poderia ser também localhost private static $usuario = 'root'; // usuário…
-
1
votes2
answers526
viewsA: Contact Form Does Not Work PHP
The problem is that you are making a header array, which should be a string, see if doing as below solves the problem: $name = @trim(stripslashes($_POST['name'])); $from =…
-
1
votes1
answer4041
viewsQ: How to select all tables containing the field with the same name?
I need to search all fields "id_category" in a given database, and bring a list of the tables that contain this field in common, which in this case is the foreign key of the table "sis_category".…
-
3
votes1
answer4041
viewsA: How to select all tables containing the field with the same name?
The way I solved it was by doing the following: SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'meu_banco' and COLUMN_NAME='id_category'; And to bring only the table name: SELECT…
-
0
votes2
answers6847
viewsA: How to avoid abrupt page breakage when printing an html table
See if this solves your case, no guarantee, put this in your CSS style sheet: @media print { table { page-break-after: always; } } or: @media print { table { page-break-inside:avoid; } }…
-
2
votes2
answers10740
viewsA: simple array arrays for json_encode
Thus also resolves: $arrayClientes = array(); if (count($clientes)) foreach ($clientes as $cliente) { $arrayClientes[] = array( "Name" => $cliente['nome'], "Email" => $cliente['email'] ); }…
-
1
votes1
answer1596
viewsA: How to display photo in modal
Pass the image through the attribute data-url to the element via the click button: <button type="button" class="btn btn-default" data-url="/path/<?php echo $IMAGEM; ?>" data-toggle="modal"…
-
0
votes2
answers754
viewsA: Change the value of a global variable within a mongoDB function?
See if this solves your case: var sistema = { variable_bool : false, acao : function(bool) { sistema.variable_bool = bool; }, getBool: function() { return sistema.variable_bool; } }; var action =…
-
1
votes3
answers3652
viewsA: print json on pure javascript screen
In the same way you do with PHP, you do with javascript, prefer the console to the place of alert(). If you press the F12 key in Chrome, will open his console, in the "console" tab there is the…
-
1
votes2
answers410
viewsA: Ajax request error to load in google map
You can use one with ssl, if you set the sensor to false, do not need to use the KEY: <script src="https://maps-api-ssl.google.com/maps/api/js?v=3&sensor=false&language=pt-br" async…
-
2
votes2
answers1196
viewsA: Curl, SSL and Security
Putting "false" does not make anything unsafe, as connection will still be SSL and encrypted. You just can’t put false if you’re doing this on a service or link that requires certificates with…
-
1
votes4
answers344
viewsA: Convert a Select with 2 option HTML to 2 Buttons
I have this example with javascript session that opens a modal in which I use the fancybox and Bootstrap: just need to create the image of the company: /img/logo_empresa.png div de overlay with…
-
2
votes1
answer77
viewsA: How do I know which script manipulated a gift and modified the HTML attributes?
I already found the solution, opened the Firefox debug and could see the files that are loaded while running.
-
1
votes1
answer77
viewsQ: How do I know which script manipulated a gift and modified the HTML attributes?
It is possible to know through the console? Imagine this story: You have several Javascript files embedded in the page header, and when you send a post, out of nowhere appears a style="display:None"…
-
0
votes2
answers645
viewsA: Make calculations based on PHP or Mysql averages
The average calculation is basically the sum of the elements divided by the number of elements. Example of average calculation: (1 + 2 + 3 + 4) / 4 = 2,5. In this sense, in PHP, you can do so:…
-
1
votes3
answers35
viewsA: Delete Line with email
The question is very poorly formulated, so you received so many negatives, I hope you edit it so that people will come back to you positive. But from what I understand, you want to filter the email…
phpanswered Ivan Ferrer 12,096 -
0
votes3
answers417
viewsA: Access different objects from a Json with Angularjs
Your JSON has a syntax error, the correct would be something like this: var data = { "status":"ok", "count":10, "count_total":54, "pages":6, "posts":[ { "id":2625, "type":"post",…
-
1
votes1
answer112
viewsQ: Should I keep the void on the link or can I leave it blank?
I’ve seen some links that contain the following syntax: <a href="javascript:;" id="el" onclick="acao()"> As far as I know, in some versions of IE, this causes a mistake, so I ask if I should…
-
0
votes2
answers101
viewsA: "Catchable fatal error" PHP error
I think this solves, because the question basically is that you are calling a method without passing value, in the class it is mandatory to pass a value, to solve you can create a second method that…
-
0
votes2
answers182
viewsA: Open different Divs via links
A more intuitive way is not to do several methods, just leave the logic inside the script, and keep the html elements independent, see: <a href="javascript:void(0);" class="open-div"…
-
0
votes2
answers312
viewsA: Change class value in jquery at a certain resolution
A simple way to solve this is like this: function videoYoutube(el, novoValor1, novoValor2) { var dados = { apiKey:'AIzaSyDEm5wGLsWi2G3WG40re-DAJcWioQSpJ6o',…
-
1
votes3
answers2702
viewsA: Dynamically populated option select list selected with Angularjs
Inside of your controller: $scope.$watch('IdCategoria', function() { $http.get("/api/Categoria/GetList", { }) .success(function(response) { if (response.length > 0) {…
-
0
votes2
answers792
viewsA: PDO vs Doctrine
Basically, the advantage is the mapping of the entities and the persistence of the data, besides having a great advantage of caching, it allows you to have a maintenance facility, using only the…
-
1
votes1
answer101
viewsQ: Deletion of multi upload files
I have the following code that includes files for upload: HTML <p>Utilize a tecla <b>Ctrl</b> para selecionar mais de um arquivo.</p> <div id="multiple_upload">…
-
1
votes3
answers561
viewsA: AJAX: Send value to php file, query using this value, and returnate a Json array
Try it like this: var enviar = function() { viewData : function(data, el) { var content = ''; for (var i in data) { var tit = data[i].titulo; var desc = data[i].descricao; var dateVal =…
-
2
votes2
answers827
viewsA: What is the best way to persist data in an application?
Your question suggests many answers, however, a good way to solve this. It’s using exceptions. Example: <?php class Form { private $data = array(); public $html; public function validationForm()…
phpanswered Ivan Ferrer 12,096