Posts by Leandro Lima • 675 points
36 posts
-
5
votes3
answers203
viewsQ: Should I always use Try catch to fix mistakes?
Sometimes when I know something may fail in my system I do a validation using if, equal is below: lista = [1,2,3] #um número que esteja entre os indices da lista numero = int(input(f'Digite um…
-
2
votes2
answers179
viewsQ: Should I compose every HTML that repeats?
One of the main advantages I understood in using Vue.js/React is to define a component and be able to reuse it where necessary. Taking this into account, I have a web application that several times…
-
1
votes2
answers118
viewsQ: Why is object property automatically transformed into a string?
I’m using Nodejs and I have this problem: I have the following object: let obj = { id : { $gte : 5 } }; console.log(obj); //Resultado: { id: { '$gte': '5' } } Note that in the result, the property…
-
2
votes1
answer88
viewsA: Doubt to take the name of an automatically generated php input field
Thus: $(document).ready(function(){ $("input[type='radio']").click(function() { var value = $(this).val();//aqui retorna o valor correto var nome = $(this).attr("name"); }); });…
-
-1
votes3
answers92
viewsA: PHP variable in Javascript
Try this: <script> $(document).ready(function(){ var duvida = '<?PHP $sucesso;?>'; document.write(duvida); var duvida = '<?PHP $fracasso;?>'; document.write(duvida); }…
-
1
votes1
answer117
viewsA: Buttons generated by foreach only execute ajax in the order they are displayed
This code below is not the best way to do this I believe. But I do not know what would be the most elegant way to do. Creates the forms with the foreach: <?php foreach ($linhas as $linha): ?>…
-
0
votes2
answers761
viewsA: Check the existence of a file
With Jquery: $.ajax({ url:'http://www.example.com/somefile.ext', type:'HEAD', error: function() { //arquiv não existe }, success: function() { //arquivo existe } });…
-
1
votes1
answer395
viewsA: Write textarea line break in database
You can use the function nl2br to do this. In his method salvarFlor you can do this: $textArea = nl2br($stringTextArea);…
-
0
votes2
answers33
viewsA: How to locate the data of the respective month
Do so: mysqli_query($sql, "SELECT data, sum(total) FROM pedidos where data >=" . date('Y-m');
-
1
votes2
answers572
viewsQ: Remove duplicate array element
I have the following array: Array ( [0] => Array ( [forn_nome_fantasia] => FORNECEDOR TESTE [class_nvl4_descricao] => DESPESAS COM FRETES ) [1] => Array ( [forn_nome_fantasia] => DJ/…
-
0
votes1
answer32
viewsA: Mouse click on <TR> of the table do not trigger the last <td>
Change your js code, use selectors :not and Nth-Child, do so: $("#grade-horario tr td:not(:nth-child(5))").click(function(){ //ações }…
-
0
votes1
answer71
viewsA: Mysql IN function but my parameter comes a string
That solves: ((tp.cod_tipo_guarda IN(TRIM(BOTH "'" FROM valores)) OR p_cod_tipo_guarda = 0) AND tp.ind_ativo = 1 )
-
1
votes2
answers76
viewsA: Problems with download in Codeigniter 3
If you are returning the header (error) 404 is because the link is broken, IE, he is not finding the file, look if the way is right. If you don’t want to be redirected to another page when clicking…
-
2
votes1
answer623
viewsQ: Validate select with jQuery Validator
I got a select like that: <form action="" id="form"> <select name="unidadeNegocio[]" id="unidadeNegocio" multiple="multiple" > <option> A </option> <option> B…
-
1
votes4
answers1339
viewsA: Send PHP command via Ajax?
What do you put in data is what will be sent to the file you put in url, in your case is the index.php, in your code, you would be passing the string "test" pro index.php. Code PHP mixed with Ajax…
-
3
votes3
answers3053
viewsA: Inserting current date in php
The function NOW() Mysql returns the current date. You can do it like this: $result_endereco = "INSERT INTO cadfor(id_pessoa, fornecedor, observacoes, data_cadastro) VALUES ('$id', '$fornecedor',…
-
0
votes3
answers1389
viewsA: View array value in php
You’re getting a array in the "new" index. That’s why the error is being triggered. If your model returns an array: Change that passage: <?php echo $situacao['novas']; ?> For that: <?php…
-
-1
votes2
answers668
viewsA: Using <pre> Inside a PHP TAG of an html value
To bring the result of the bank with line break use the function nl2br. In your case it looks like this: <input type="text" id="texto-os" style="height: 150px;" name="texto_os"…
-
2
votes3
answers80
viewsA: Display only one message at the end of an operation within a WHILE
//código ocultado $mensagem = ""; // declara essa variavel antes do while //código ocultado while($busca->fetch()){ //código ocultado …
-
3
votes2
answers57
viewsA: How to keep the variable with the same value in the database?
That should solve: if($nome == ''){ $nome = null; } $sql = "UPDATE `clientes` SET nome = coalesce('$nome', nome), apelido = '$apelido', telefone = '$telefone', celular = '$celular', email =…
-
0
votes3
answers5883
viewsA: Disable button after click
Suppose you use Jquery: <button onclick="dasabilitaBotao(this)">Curtir</button> <script> function desabilitaBotao(element){ $(element).prop('disabled', true) } </script>…
-
1
votes2
answers49
viewsA: Parse error: syntax error, Unexpected ','', expecting ']' in D: wamp64 www PROJETOS- sist-Crop jcrop m2brimagem.class.php on line 40
It’s a syntax error. That solves the problem: $extensoes_validas = array('jpg','jpeg','jpe','gif','bmp','png'); $this->extensoes_validas = $extensoes_validas;
-
0
votes2
answers38
viewsA: Problem with running SQL through FORM
The error is in your PHP code. Instead of you putting it on: if($_REQUEST['alterarStatus']){ $alterarStatus = trataaspas($_REQUEST['alterarStatus']);} if($alterarStatus=="aprovado"){ $SQL = "update…
-
0
votes4
answers286
viewsA: Put Required in function
This way it’s much easier, it should help you: <!DOCTYPE html> <html lang="en"> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport"…
-
2
votes1
answer30
viewsA: insert Mutiplos data already having data in db
I think that solves: UPDATE tabela SET coluna = CONCAT(coluna , ',' , novovalor) WHERE coluna = x
-
0
votes4
answers296
viewsA: Losing array elements when switching pages?
When you place a number and click on "Add Array", that number will be "pushed" in the array $cesta. However, after that you redirect to index.php, when you redirect, you lose what was inside $cesta,…
phpanswered Leandro Lima 675 -
3
votes2
answers442
viewsA: How to calculate the percentage of Likes?
I applied the formula (likesPositives/totalLikes) * 100 = percentage <?php $likesPositivos = 5000; $dislikes = 2500; $totalLikes = $likesPositivos + $dislikes; $porcentagem =…
-
2
votes2
answers93
viewsA: Error fetching database data
You are returning the variable $result as string. In your Cód is like this: if($busca > 0){ $_SESSION['id'] = $linha['id']; $_SESSION['nome'] = $linha['nome']; $_SESSION['rua_num'] =…
-
1
votes2
answers809
viewsA: How to use 2 Submit separately in html?
I split into 2 forms different. I think this solves your problem: echo "<form action='' method='POST' enctype='multipart/form-data'> <input type='text' name='ID' id='ID' placeholder='INSIRA…
-
1
votes2
answers544
viewsA: On-demand paging with PHP POST button and method using PDO
HTML/JS Code <script type="text/javascript"> $(document).ready(function(){ jQuery('#btnpaginas').click(function(){ var dados = jQuery( this ).serialize(); jQuery.ajax({ type: "POST", url:…
-
1
votes4
answers115
viewsA: How to avoid the repetition of requires?
It’s not the best way to do it, I think it’s bad practice to do it, but you can create a file called "includes.php". In this file you give the require_once() of all the files you need. Once you’ve…
phpanswered Leandro Lima 675 -
0
votes2
answers15636
viewsA: Sending form to database with Mysql, Html and php
The query you put in the variable $string_sql is considering the variables $nome, $email e $testemunho as string. The right way to do this, i.e., for variables not to be considered string, has to be…
phpanswered Leandro Lima 675 -
2
votes1
answer150
viewsA: Reuse the function in javascript
It would be about the same as it is below, but the onmouseover="mostrardiv(this)" would have to be inside the element tag you want to catch the ID. <div class="col-md-2"…
-
0
votes1
answer450
viewsA: Upload a file with JS
You have to send one FormData to upload images with Ajax. var form = $('#meuForm')[0]; $.ajax({ type: 'POST', url: 'AJAX/AJAX_carregarExcelParaFretes.php', data: new FormData(form), processData:…
-
-2
votes2
answers692
viewsQ: Because "PHP and MYSQL"
I started learning PHP very little time ago and I have done a lot of research on the subject. I have a question that may seem kind of obvious and "silly" to most of you. My doubt is, because most of…
phpasked Leandro Lima 675 -
2
votes1
answer2727
viewsQ: How does callback work in PHP?
I was studying a little PHP until I came across this code: $this->form_validation->set_rules("nome", "nome", "required|min_length[5]|callback_nao_tenha_a_palavra_melhor"); public function…