Posts by Ivan Ferrer • 12,096 points
772 posts
-
2
votes6
answers22962
viewsA: How to calculate percentage?
I usually do so to capture the result of a discount: $total = 4000; $pctm = 30.00; $valor_com_desconto = $total - (($total * $pctm) / 100); echo $valor_com_desconto; Obs: mathematics always executes…
-
1
votes2
answers260
viewsQ: How to check the 4 vertical and horizontal elements in a matrix based on the current position?
Let’s assume I have a matrix this way: $matrix = [[0, 1, 1, 0], [1, 1, 1, 0], [1, 0, 0, 0]]; Imagine that you are making a loop and capturing the position of this matrix as the example below, being…
-
1
votes2
answers51
viewsA: Error registration report on method return
The correct in this case would be to do your query this way: Obs: traded date for data_cadastre, because date is a reserved word of Mysql and will therefore return with error. Another detail is how…
-
0
votes2
answers168
viewsA: PHP - Foreach auto tuning
I don’t know exactly what you want to do, but here’s an example: $dadoUsuario = array('... vem os dados do banco'); function getDadosUsuario($item, $key) { $parseNames = explode(' ',$item['nome']);…
-
1
votes2
answers795
viewsA: Structure of a chained JSON
I suggest you do the array structure, and then convert to json: $array_data = array( 'cidade1'=>array( 'textheader'=>'Lorem Ipsum dolor', 'chart1'=>array('valor1'=>30, 'valor2'=>350),…
-
1
votes3
answers9083
viewsA: Enable and disable a form edit button - with PHP
EDITED to satisfy the need with old version without use of mysqli: <?php $params = array("M",1); // query $sql = "select * from tabela where sexo ='{$params[0]}' and id ={$params[1]} "; $query =…
-
1
votes1
answer289
viewsA: Add get parameters with a select/option value in the url
I suggest doing this in ajax: $("select.ordenacao").change(function() { $("select.ordenacao").each(function() { str = $( this ).val(); ordenar(str); //$("#ordenar").submit(); }); }); var ordenar =…
-
6
votes1
answer173
viewsQ: What is the difference between the two array structures and their repetition loops in Javascript?
I would like to know which is the best way to work with arrays? var meu_array = new Array(1, 2, 3); var meu_array = [1, 2, 3]; There is some difference in performance between the 6 cases presented…
-
1
votes2
answers233
viewsA: How do I display the customer name of a particular sale? I’m not getting the name with get
From what I can see, the error is more banal than it seems. You are quoting and do not have to put this in your query query and test using same name for product and for name, in this case create a…
-
2
votes3
answers192
viewsA: Problem with variable concatenation
Within your foreach, collect in an array, all Ids, and at the exit of the foreach perform the function implode() PHP to transform into a string with interleaves of the separator you need: $ids =…
-
0
votes1
answer58
viewsA: Write to two or more Mysql tables
I don’t know which language you are used to working with, but you could record each of the events in a session (SESSIONS) by storing the id of the event executor, and set a save time to record the…
-
5
votes2
answers143
viewsA: Translate site that is already developed
You can do it two waysThe laborious: Create a sheet with all possible variables in a library and translate the contents using a file of type . ini and use parse_ini_file():…
phpanswered Ivan Ferrer 12,096 -
1
votes2
answers201
viewsA: Processing of data output from PHP database
You can do this in both PHP and SQL, but I usually store the user scroll data in a table of roles. In SQL, just create two aliases and take one formatted and one unformatted for the name: SELECT…
-
1
votes2
answers1388
viewsA: How to save facebook profile photo in database?
You can directly access the image json: https://graph.facebook.com/4?fields=picture.width(750).height(750) Example: function getImageFacebook($id) { $url =…
-
1
votes2
answers858
viewsA: Calculate time difference in Angularjs
See if any of these help you in what you need: simple: http://jsfiddle.net/ivanferrer/b60djmho/ at intervals: http://jsfiddle.net/ivanferrer/1cyxoytv/…
-
2
votes2
answers435
viewsA: What are Exceptions and how should I create and embed them in PHP
Here is an example of good practice for treating exceptions, because in addition to creating a componentization and documenting your system, it allows no one below to destroy its functioning:…
-
1
votes3
answers4509
viewsA: Print orientation using Javascript, CSS, HTML or PHP
If the server platform is Windows. What you can do is create a macro in VBS to do this. Create the file: Worksheet.vbs $file = 'seu_arquivo.xls'; $path = "C:\\temp\\"; $fp =…
-
2
votes2
answers1121
viewsA: PHP7 anonymous class. What are the advantages?
There are some advantages: Before understanding its advantages, it is also necessary to understand the importance of anonymous methods (closures), such as methods that allow callback (i.e., the…
-
1
votes2
answers2583
viewsA: Change Form Field Type with onclick
Follow another example to answer the duplicate question: Change option of a select via javascript <?php if($_POST) { if (isset($_POST['grupo'])) { $grupo = $_POST['grupo']; if (in_array($grupo,…
javascriptanswered Ivan Ferrer 12,096 -
0
votes4
answers2204
viewsA: Multiple items in a Mysql column
I agree with Wallace’s observation, Edgar’s answer, is very insecure. It will work until it breaks down in the first problem. To enter the data, you can serialize the data and write to the database:…
-
2
votes2
answers491
viewsA: Transform a PHP variable into an array
PHP is a server language, that is, the script is sent to the server, it is processed and then returns the output, since javascript is a client language, it is not sent to the server to process, so…
-
26
votes2
answers32776
viewsA: URL friendly, how to make it work with HTACCESS
The flag QSA, informs that only QUERY_STRING you can access them. The flag NC (nocase), is to ignore case sensitive (high/low box). The flag L (last) is a flag to indicate that the current rule must…
-
0
votes2
answers55629
viewsA: CORS - No 'Access-Control-Allow-Origin' header is present on the requested Resource
The problem should be permission to use CORS in your apache, try putting this in the file .htaccess: Header set Access-Control-Allow-Origin "*"
-
1
votes2
answers2057
viewsA: Consuming Json with Angularjs
The problem is that your server needs CORS access in order to run JSON output, put this in the header of your JSON output: header('Access-Control-Allow-Origin: *'); And for your entire application,…
-
2
votes1
answer7226
viewsA: How to run a PHP database
From what I can tell you’re mixing mysql_* on connection and calling query with mysqli_*. The method you need to use is basically this: //conecta no banco $connection = mysqli_connect("localhost",…
-
1
votes1
answer374
viewsA: Search for closeness
In PHP that’s basically it: public function getGeocodeAddress($lat, $long) { $url = "https://maps-api-ssl.google.com/maps/api/geocode/json?latlng=" . $lat . "," . $long . "&sensor=true"; $data =…
-
1
votes2
answers246
viewsA: How to make a "Hello Word!" that way
I found the solution: var helloWorld = function () { // Hello World! var start = [,,,,,,,,,,,,,,,,,,,].length, end = [,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,].length;…
-
10
votes2
answers246
viewsQ: How to make a "Hello Word!" that way
Without using the items below: String-like strings and functions before output Numbers Regular Expressions Functions with the names: "Hello", "World", "Helloworld" or anything similar only the…
-
0
votes2
answers769
viewsA: How to check if the class was instantiated via Dataprovider using PHP Unit
I ended up arriving at the solution alone, to test an instance just do the following, as described in the documentation:…
-
-1
votes2
answers91
viewsA: LEFT JOIN with three tables gone wrong
Try this, and see if it works, I didn’t test it, glue the structure of the tables so I can test it here: SELECT TOTAL.* FROM ( SELECT ofertas.id, ofertas.titulo, ofertas.descricao, ofertas.valor,…
phpanswered Ivan Ferrer 12,096 -
5
votes1
answer2597
viewsA: Help with installing Ionic Framework for Mobile Development
Like me, there must be other people who have suffered in this, so I’ll leave the answer that solved my problem: 1) I downloaded the installation package: wget…
-
2
votes1
answer2597
viewsQ: Help with installing Ionic Framework for Mobile Development
To install the nodejs more clearly, I followed the example given through the site below, in the error note below, says that the version I am using is: 0.13.0-pre…
-
5
votes4
answers6626
viewsA: What SQL command shows the maximum number of active connections to the Mysql database?
To list all bank status, type: SHOW STATUS; And to pick up running events, including the one below: SHOW STATUS where Variable_name='Com_show_status'; To get only connection status: SHOW STATUS…
-
1
votes2
answers43
viewsA: Retrieve and Print selected value of a <select>
Try this, I think it should already solve: $(function(){ $('#resultado_team2_CSGO').on('change', function (e) { var optionSelected = $("option:selected", this); var valueSelected = this.value;…
jqueryanswered Ivan Ferrer 12,096 -
2
votes1
answer773
viewsQ: How to make this directive return in ng-bind the sum of the results?
angular.module( 'isfModFinance', []) .directive( 'isfModFinance', function() { var validElementScope = angular.element('<div>{{ model.input }}</div>'); var validElementTotal =…
-
0
votes2
answers737
viewsA: Change element with jquery
The problem is you’re repeating the id of the element within its foreach, only he doesn’t take everyone’s collection id=produto and not at all id=quantidade because the id attribute is only…
-
0
votes3
answers164
viewsA: Return the id of a table in another table
Create a foreign key for the table aprovacao: ALTER TABLE `aprovacao` ADD CONSTRAINT `fk_id_cliente` FOREIGN KEY ( `ID_CLIENTE` ) REFERENCES `clientes` ( `ID_CLIENTE` ); Then just update the data by…
-
1
votes2
answers81
viewsA: What’s the risk with this intel?
To N ways to insert data, delete, join tables, etc. In a simple query like this... Here’s a classic and basic example to ignore the path: $valorGet = "';DELETE FROM tabela WHERE 1=1;-- "; $sql =…
-
1
votes1
answer152
viewsA: How JSON works in a project
JSON is a structure similar to XML, notation, which can be recognized through javascript, which basically can contain values, arrays and objects, you can check more information here: What is JSON?…
-
0
votes2
answers1439
viewsA: How to export query to CSV with each column in a cell?
For the sake of better performance, and use of the PHP language, I recommend using the PHP Excel library: https://github.com/PHPOffice/PHPExcel Now an example of how to implement the method with PHP…
mysqlanswered Ivan Ferrer 12,096 -
0
votes2
answers769
viewsQ: How to check if the class was instantiated via Dataprovider using PHP Unit
Could someone make an example? Considering my class below: class MinhaClasse { private $param; public function __construct(array $params = []) { $this->param = $params; } } I have my test class:…
-
5
votes1
answer1015
viewsQ: Why is it recommended to place Javascript codes at the end of the body tag scope?
Do you have any rules regarding the use of scripts in tag <head>? W3C did not make the rules of use very clear.
-
0
votes2
answers350
viewsA: PHP - how to use placeholders for form validation messages
Maybe the problem is that the attribute color is not picking because of the bootstrap priority, you can use "! Important" so that no css interferes in the element’s color:…
-
1
votes1
answer306
viewsA: Vertical menu with filter inside the sub-menu
You can create such a filter: $('#filter').on('keyup', function(){ var dataFilter = $(this); var valorBusca = dataFilter.val(); var contaLetras = valorBusca.length; if (contaLetras >= 1) {…
-
3
votes2
answers93
viewsA: Can anyone explain this logic to me in Wordpress?
This logic is also part of PHP, but the difference in Wordpress is that he created his own methods for each action with the database, using a class: <?php //declara a variável $i como 0 para no…
-
1
votes4
answers6197
viewsA: Resume all values in stdClass Object Array
This is an array of objects, as an example I made the following entry from your collection: <?php $myCollection = [ new stdClass(), new stdClass(), new stdClass(), ]; //como no seu exemplo, você…
phpanswered Ivan Ferrer 12,096 -
3
votes4
answers2160
viewsA: When filling in the Date field, perform a jQuery action
The solution to your problem would be something like this: $(function(){ $('#dp1').on('blur', function(){ alert('Sua lista!'); }); });
-
0
votes2
answers432
viewsA: PHP - problem with Unlink
Probably the file has been deleted and the system is trying to re-exclude a file that no longer exists, generating an error, try doing this: if (file_exists("../../img/portifolio/{$excluir_img}")) {…
phpanswered Ivan Ferrer 12,096 -
1
votes2
answers1581
viewsA: Folder browsing in PHP
You can also use this method: function gerenciarArquivos($path) { $files = glob($path."*.{jpg,png,gif}", GLOB_BRACE); $listFiles = array(); if (count($files)) { $listFiles[] = "<ul>"; foreach…
-
3
votes3
answers360
viewsA: Input type="text" field does not fill data with more than one word
I believe the problem is the lack of quotation marks on the value="", he is treating the word "World" as if it were an attribute of the text field, ie its output should be: <input type="text"…