Posts by vmartins • 601 points
23 posts
-
1
votes1
answer138
viewsA: Search name region/city php
There is no automatic way to find out the precise location of the user, unless asking for it ;) You can get the user’s approximate location through their IP address. You can use a service such as…
-
1
votes1
answer122
viewsA: Capture ajax datetime with jquery
Use the library Moment js. to convert date/time. Example: moment('2016-07-15T10:00:00-0300').format('hh:mm'); https://jsfiddle.net/j51b2mqn/…
-
0
votes2
answers89
viewsA: How to simulate click only one button and not both?
To take an element by the value in jQuery, use the selector value=[]. Example: <input type='button' class='botao' origin='Roll < 49' value='Roll < 49'/> <input type='button'…
-
1
votes2
answers1837
viewsA: Group column sum by quarter
select CASE WHEN MONTH(data) in (1,2,3) THEN 'Primeiro' WHEN MONTH(data) in (4,5,6) THEN 'Segundo' WHEN MONTH(data) in (7,8,9) THEN 'Terceiro' WHEN MONTH(data) in (10,11,12) THEN 'Quarto' END AS…
-
3
votes2
answers526
viewsA: Convert php code to reply ajax
A PHP page being called via Ajax or via "normal" has the same code. What can differentiate is the format of the return. In your case, you are printing a string with Javascript code (which is not…
-
2
votes2
answers117
viewsA: Should I validate data in javascript and php?
1) Always validate data! 2) Study more about protection CSRF. If you want to prevent robots from accessing this page directly, then I suggest you put a CAPTCHA.…
-
1
votes1
answer117
viewsA: Retrieve dynamically generated checkbox values
In PHP you get the values of a multiple checkbox the same way you get a normal checkbox. The difference is that it returns an array. In your case, if you print the variable $_POST['regional'], will…
-
3
votes3
answers611
viewsA: Calculating in Table Fields with JS
A solution with jQuery would be: $('[name="percentual"]').on('keyup', function() { var percentual = $(this).val(); if ($.isNumeric(percentual)) { $('#tabvenda tbody tr').each(function() { var…
-
1
votes1
answer67
viewsA: count record based on variable
Use Mysql’s BETWEEN to search for a range. $sql= mysqli_query($conn,"SELECT caixa, data, COUNT(*) FROM clientes WHERE caixa = '{$caixa}' AND data BETWEEN '{$datade}' AND '{$dataate}' GROUP BY caixa,…
-
0
votes2
answers412
viewsA: How to send the result of a query by e-mail SHELL SCRIPT
echo $campanha | sendmail -s "CAMPANHAS" [email protected]
-
2
votes1
answer79
viewsA: Cannot add or update a Child Row
Only after you run the query (with mysql_query()) is that you will be able to get the id inserted (with mysql_insert_id()). Example: $query_identificacao = "INSERT INTO identificacao…
-
2
votes1
answer105
viewsA: Group on an equal footing
SELECT group_concat(user) user, cores FROM ( SELECT user, group_concat(cores ORDER BY cores ASC) cores FROM escolha INNER JOIN cores ON cores.escolha = escolha.id GROUP BY user ) tmp GROUP BY cores…
-
1
votes1
answer592
viewsA: mysql - Query to convert columns into rows
I could only think of something like: SELECT * FROM ( SELECT 'assiduos_a1' AS 'Label', assiduos_a1 AS 'Valor', inscricao, max(data_inclusao) FROM cli_agendados_assiduos UNION SELECT 'assiduos_a2' AS…
-
0
votes2
answers2243
viewsA: Count lines with PHP and JS
To get javascript for the total number of lines in a textarea, you can do something like: seu_textarea.value.split('\n').length Example: http://jsfiddle.net/yTRwD/ In PHP, you can use the function…
-
1
votes2
answers186
viewsA: Web service, play dice in empty field bd error
His latest foreach (more internal), is running through a $subgroup in search of products, but within the subgroup there is also an item called observation, so he is bringing data of "observation"…
-
1
votes2
answers746
viewsA: How to generate a sequence of dates from start and end dates?
You can do something like: data_inicio = new Date('2014, 03, 19'); data_fim = new Date('2014, 04, 13'); achou = false; i = 0; while (!achou) { data_tmp = new Date();…
-
0
votes4
answers3446
viewsA: Javascript function for zeros on the left with MVC 5
Use the function below (source) to fill a string for a certain size with another string: function str_pad(input, pad_length, pad_string, pad_type) { // discuss at:…
-
0
votes3
answers210
viewsA: timestamp does not indicate the correct date
You can bring the correct Mysql date/time using the function FROM_UNIXTIME() SELECT FROM_UNIXTIME(article_timestamp, '%W, %d de %M de %Y %h:%i:%s') FROM sua_tabela…
-
1
votes3
answers3112
viewsA: How to check if a file exists in several different folders?
<?php $arquivo = "foto.jpg"; $diretorios = array('img', 'img-2', 'img-3', 'img-4', 'img-5'); foreach ($diretorios as $dir) { if…
-
0
votes2
answers703
viewsA: Select an array based on the value of an internal key
<?php $pais = array(); function obter_pais($filho, $chave, $identificador) { global $pais; if (in_array($identificador, $filho)) { $pais[] = $chave; …
-
3
votes1
answer1072
viewsA: How to find out who requested a particular PHP file?
You can look in the apache access log file. Generally in linux it is in /var/log/apache2/access.: $ grep nome_arquivo.php /var/log/apache2/access.log Or put in your PHP file to display the IP…
-
10
votes5
answers141242
viewsA: How to get the current date and time without using the computer clock?
You can get the date and time from a server NTP. Follow an example of PHP code that does this: <?php $socket = fsockopen('udp://pool.ntp.br', 123, $err_no, $err_str, 1); if ($socket) { if…
-
4
votes4
answers9080
viewsA: Select2 with AJAX
Follow an example from Lect2. HTML <input type="hidden" class="select2" /> Javascript $(".select2").select2({ placeholder: "Buscar", minimumInputLength: 3, ajax: { url:"/echo/json/", dataType:…