Posts by Ivan Ferrer • 12,096 points
772 posts
-
3
votes2
answers1146
viewsQ: How to make a regular expression to remove only the hyphen without removing the hyphen arrow
I have the following expression: 00000-001->22222-222 I wish she’d stay like this: 00000001->22222222 I’ve tried so many ways on this website, but I’m not getting it.…
-
2
votes2
answers5838
viewsA: Copy data from one column of a table to another of the same table
Just change the type, it will solve the problem: ALTER TABLE `nome_da_tabela` CHANGE `nome_da_coluna_inteiro` `nome_da_coluna_decimal` DECIMAL (6,2); And to copy the data, you can make a select…
-
0
votes3
answers55
viewsA: Difficulty in formulating query
See if this solves your problem: select * from `Parcela_FamiliaParcela` `pfp` left join `FamiliaDeParcelas` `fdp` on (`fdp`.`cod_familia`=`pfp`.`cod_familia`) left join `Usuario` `u`…
sql-server-2008answered Ivan Ferrer 12,096 -
0
votes1
answer260
viewsA: Capture the entered value in the input to submit using jQuery
I found the solution, instead of using the direct click event on the button, I passed the event to the form (Submit), and using delegate, I was able to work with the parameters and attributes of the…
-
0
votes1
answer260
viewsQ: Capture the entered value in the input to submit using jQuery
I need to lock the shopping cart of a shop made in Prestashop, until the person type the email, or log in, after he insert a merchandise in the cart. Then I made the following implementation in…
-
2
votes2
answers510
viewsA: Return response problem via $http.post()
The concept is very simple, this is a JSON object, so you have to play it in a variable and use it as in the example below, you can either query by position, or in a loop, by your controller, you…
-
0
votes1
answer259
viewsA: How to create an instance of a Prestashop module within a controller?
I solved the problem by doing so: require_once './modules/cpfmodule/cpfmodule.php'; $cpfmodule = new cpfmodule(); edited so far: I further improved the code above, doing so: $cpfmodule =…
-
0
votes1
answer259
viewsQ: How to create an instance of a Prestashop module within a controller?
I would like to create an instance inside the control of a particular module to be able to validate it in the Prestashop authenticator pattern: I am using Prestashop for the version: 1.6.1.3 Path to…
-
0
votes0
answers3643
viewsQ: How do I share a direct URL or image on Instagram?
How it’s done on Facebook: http://www.facebook.com/sharer.php?u=<?php echo MINHA_URL;?> And on Twitter: https://twitter.com/intent/tweet?text=<?php echo TEXTO.' '.MINHA_URL?> I walked…
-
1
votes6
answers3120
viewsA: How can we not allow numbers in a textbox?
A simple way to solve this is like this: function isNumber(el) { var reg = /[0-9]+/; if ( reg.exec(el) ) { return true; } return false; } $(document).ready(function () {…
-
1
votes1
answer756
viewsQ: How does Flash Messages work on ZF 2?
I’m working with the Zend Framework 2.0 and I noticed that he has a helper for handling error messages, called "flashMessages", which I didn’t understand straight away is whether he captures this by…
-
3
votes1
answer624
viewsA: How does data-Binding work in Angularjs?
Most template systems link data in only one direction, which merges with the model components, and this in turn, performs an output on your screen (this is the default data-Binding event). After…
-
0
votes3
answers186
viewsA: Use interfaces to abstract connection type
One way to do it would be like this: interface InterfaceFabrica { public function __construct(DatabaseConnect $databaseConnect); } It would have a class for the type as addiction injection: class…
-
0
votes3
answers485
viewsA: Error inserting data into Mysql - Codeigniter
The problem is basically in the query, it seems that he is trying to insert the value of a string as number, and gives error, try to cast a type: <?php $chave =…
-
0
votes4
answers1091
viewsA: HTML DIV ID set with echo
I believe this should solve the problem: <script> function display(pos) { var elem = document.getElementById("disp" + pos); alert(elem); if (elem.style.visibility == "hidden") {…
-
16
votes4
answers47097
viewsA: Take select value with jquery
Try it like this: $("#QtdAdomodacaoDuplo option:selected").each(function() { var QtdAcomodacaoD = $(this).val(); }); or: var QtdAcomodacaoD = $("#QtdAdomodacaoDuplo option:selected").val();…
jqueryanswered Ivan Ferrer 12,096 -
2
votes2
answers487
viewsA: Add product value
One simple way to solve this is through the change event, passing the form value to the other field: With jQuery: /* "campo_valor" é a id do input e "combo" é a classe do elemento select */…
-
1
votes2
answers410
viewsA: How to use sprintf to mount an SQL query?
I changed the name of your database date field, because the word "date" is a reserved Mysql variable, and should not be used as a field name. No need to use the function sprintf(), The mysqli…
-
2
votes1
answer62
viewsA: Correct way to send values through PDO
There are 3 ways you can do this the right way, using with Prepared statement: passing as parameter: $sth->bindParam(':param', $param); passing as value: $sth->bindValue(':value', $value)…
-
1
votes0
answers45
viewsQ: Installation of a new theme in the Prestashop store 1.4.3
I installed a theme using the module: export/import Theme, as shown in this video : and now I’m getting this message in the header: Fatal error: Uncaught Exception 'Smartycompilerexception' with…
-
2
votes3
answers252
viewsA: Use of preg_replace invalidates password with SHA1
A way to filter sha1 would be so: function isSHA1($sha1) { return (bool) preg_match('/^[0-9a-f]{40}$/i', $sha1); } If you are using PDO for example, you can do so: $dbh = new…
-
0
votes4
answers79
viewsA: Dar Selected at a given value received in the JS function
Doing so will already work: function editarEtapaProjeto(data) { for (var i in data) { $('#'+data[i][0]).val(data[i][1]); } } var data = [ {'etapa_projeto_id', 1}, {'etapa_id', 2}, {'dias_total',…
-
0
votes4
answers3189
viewsA: Access JSON with multiple JS objects
Works perfectly here, just declare the variable i: Javascript: var response = [ { "id": 1, "nome": "Matheus Almeida Siccenna", "cpf": null, "matricula": { "id": 555, "empresa": 1, "unidade": 0,…
-
0
votes2
answers784
viewsA: How to implement an SVG?
Look at this example I did on Jsfiddle, the link has the reference of where I produced the image, just click HTML preview, and then in the console take the source code.…
-
0
votes3
answers7147
viewsA: Stop executing a Javascript function to perform another function
A simple IF condition would not solve the problem? var executandoAcao = function () { for (var j = 0; j < $kinvey.arrayIdColetor.length; j++) { drawLatLong(j, $kinvey.arrayIdColetor); } return…
-
1
votes2
answers4279
viewsA: Export data to Excel using PHP Excel
I created a class model to do the entire export process using Phpexcel, I believe it can also serve your purpose: require_once("./PHPExcel/Classes/PHPExcel.php"); class ExportData { private $data;…
-
6
votes1
answer462
viewsQ: What is the difference between the Mysql Trigger and Mysql Event exception?
I would like to create a e-mail trigger scheduler, without the use of cron, and would like to know if it is possible to do this through Mysql. Searching the Internet I saw some examples of event…
-
0
votes2
answers620
viewsA: Validate xml file before updating database
You can simply read your file and check the amount of columns for each item in your XML: $xmlFile = <<<EOF <?xml version="1.0"?> <table> <row> <column> 131290444…
-
2
votes4
answers1821
viewsA: String and variable concatenation problem in jquery load function
Try this using the jQuery method even, below I created a JSON for each parameter: $(document).ready(function(){ $('#estados').change(function(){ var params = { cliente:$('#idcl').val(),…
-
0
votes0
answers78
viewsQ: How to implement Design Pattern for a microservice proxy?
Soon we will make our applications through Middleware, I know that the authentication of the systems will be through Oauth2, but I have the following doubt: Where I should start studying related…
-
-1
votes5
answers6529
viewsA: How to create buttons to increase/decrease font?
I had to do it once on a project, see if it fits you: function strReplace(haystack, needle, replacement) { var temp = haystack.split(needle); return temp.join(replacement); }…
-
1
votes2
answers73
viewsA: Ordering object array by name
To sort objects use the function sort(), here is more information. arrayVelho.sort(function(a,b) { if(a.TXT_NOMEX_PESSO < b.TXT_NOMEX_PESSO) return -1; if(a.TXT_NOMEX_PESSO >…
javascriptanswered Ivan Ferrer 12,096 -
15
votes4
answers3410
viewsA: What is dynamic programming?
When you start working with more than one system, you can run a series of conflicts due to the use of recursive algorithms, which re-examine the same problem many times, and in this situation,…
-
1
votes2
answers2360
viewsA: How to count number of records in a table?
A simple query by id, already solves: SELECT COUNT(*) AS total_comentarios FROM comentarios where id_noticia=:id
-
0
votes2
answers68
viewsA: How to rewrite the initial array and remove items by the ID in the view with Smarty?
I managed to solve the problem by doing so: {if isset($products)} {assign var='remove_products' [712, 716, 717, 718, 719, 720, 745, 755, 758]} {assign var='n_products' []} {foreach from=$products…
-
1
votes2
answers68
viewsQ: How to rewrite the initial array and remove items by the ID in the view with Smarty?
I’m using the View rendering library with Smarty. In my view, I have an output with the product information array inside a foreach: {assign var='remove_products' [712, 716, 717, 718, 719, 720, 745,…
-
7
votes5
answers31061
viewsA: Format Float value as currency using Jquery
You can do so, that also works: function currencyFormatted(value, str_cifrao) { return str_cifrao + ' ' + value.formatMoney(2, ',', '.'); } Number.prototype.formatMoney = function (c, d, t) { var n…
jqueryanswered Ivan Ferrer 12,096 -
1
votes3
answers124
viewsA: How to use multiselect value in php
The correct answer depends on how you sent the data via ajax, whether it was through the POST, GET or PUT method... But assuming that you sent via POST, the data received is apparently an array, in…
-
-2
votes3
answers1074
viewsA: Add a comma to each word
Based on your example, just do this: $descricao = 'titulo de teste'; //aqui ele limpa espaços duplos, e substitui por um espaço $descricao = preg_replace('/\s+/', ' ',$descricao); $keywords =…
phpanswered Ivan Ferrer 12,096 -
1
votes5
answers1793
viewsA: Login system with PHP
Briefly: As you are starting now, the first step I can suggest to study, before making a login and password system, is to follow the normalization of Psrs, After all, we don’t want any more bad code…
-
0
votes5
answers1346
viewsA: How to get all HREF and SRC values from a code
I believe the simplest way to do this, is to take all the HTML directly in the post and send it to the attribute search process, see how I solved the problem: HTML <h2> Cole o HTML:…
-
0
votes2
answers213
viewsA: Function with in_array is not working
The first parameter must be the value to be searched for, and the second parameter is the array itself. in_array('valor', array('valor', 'valor1', '...')). See that you are passing the array in the…
phpanswered Ivan Ferrer 12,096 -
2
votes4
answers632
viewsA: How to execute two querys in a statement?
Has a simple form: SELECT COUNT(*) as total_linhas, IF(valor < 1, COUNT(*), null) as total_maior_que_um FROM tabela
-
2
votes2
answers796
viewsA: Is it possible to instantiate a class without calling the constructor in PHP?
The constructor method is not required to create an instance of the class, it is only done to set the initial values when creating its instance. This occurs when it invokes the constructor, the…
phpanswered Ivan Ferrer 12,096 -
0
votes3
answers120
viewsA: Problem With PDO
Your code is confused, you’re calling the key value, for it to be key, it would have to be $resultado as $key => $value, and yet, the fetchObject(), gets the next record and returns as an object,…
-
6
votes1
answer1350
viewsA: How to show message in contact post return
To start thinking about doing the validation in PHP, calling a page via ajax, instantiating the class as below: class SendEmail { private $nome; private $email; private $telefone; private $cidade;…
-
10
votes1
answer196
viewsQ: How do I know when to use each of the execution functions?
How each of the PHP functions works: pcntl_exec('/caminho/executar'); exec('/caminho/executar'); shell_exec('/caminho/executar'); Is there any singularity between the 3 examples cited above?…
phpasked Ivan Ferrer 12,096 -
6
votes5
answers23670
viewsA: How to make Javascript calculations accepting comma to separate decimal places
Let’s assume that the amount formatted in cash is: R$ 1.234,53 In the example above you will have semicolon, in this case, if you use the .replace(',','.'), your outgoing number would be something…
javascriptanswered Ivan Ferrer 12,096 -
0
votes4
answers124
viewsA: Help in refactoring jquery code
To compress this code, you can do the following: function eventInElement(elEvent, elCSS, evento) { $(elEvent).on(evento, function() { elCSS = (elCSS == null) ? this : elCSS; if (evento ==…
jqueryanswered Ivan Ferrer 12,096 -
3
votes2
answers2815
viewsA: Deleting data automatically after certain time
Record the initial and final date he entered the category and leave the server scheduled to check if it is between the 10-day period, if it did not pass it removes the data. You can program a…