Posts by Gato de Schrödinger • 2,367 points
141 posts
-
-1
votes2
answers57
viewsA: How to receive with $_POST in PHP a value that was sent via Urlsearchparams (urlencoded) with Javascript Vanilla fetch?
The problem was that I was not using "then()". For being a Promisse, fetch() requires the use of "then()" to return your resolves(), or "catch()", so that your Reject(). Follows below the two forms…
-
-2
votes2
answers57
viewsQ: How to receive with $_POST in PHP a value that was sent via Urlsearchparams (urlencoded) with Javascript Vanilla fetch?
I would like to know how to receive the data in php with $_POST, and the data comes from a request that is sent via JS Fetch. With Formdata (Multipart/form-data) I get good. The problem is that in…
-
1
votes2
answers1203
viewsA: How to create a mask for Brazilian currency with character limit?
An alternative with a smaller code. function mascaraMoeda(event) { const onlyDigits = event.target.value .split("") .filter(s => /\d/.test(s)) .join("") .padStart(3, "0") const digitsFloat =…
-
7
votes5
answers287
viewsQ: How to go through an array of objects, add specific properties and unify those objects where it has a specific property equal to another?
I have an array of objects that have this structure below: listaProdutos = [ {nome:'Teclado',preco:28.00}, {nome:'Mouse',preco:36.00}, {nome:'Monitor',preco:500.00}, {nome:'CPU',preco:800.00},…
javascriptasked Gato de Schrödinger 2,367 -
0
votes2
answers87
viewsA: How to authenticate a user when the "username" field receives values that can reference different columns in the database table?
I made a customization (a separate method) that checks whether the data, which the user used to try to log in, matches one of the database columns (email, Cpf or phone). See this method that has…
laravelanswered Gato de Schrödinger 2,367 -
1
votes1
answer170
viewsA: How to take the third value of an object array
Buddy, I’ve done three ways here to try to solve your problem. The first is to display in case it is an array with only one object (which was the one initially presented in your question). The other…
-
2
votes2
answers87
viewsQ: How to authenticate a user when the "username" field receives values that can reference different columns in the database table?
I have a login form where I have the fields "username" and "password". The difficulty I have been finding is the following: I want to give the option of the user to log in by CPF, email or phone (in…
laravelasked Gato de Schrödinger 2,367 -
4
votes1
answer38
viewsA: AND operator doubt in Mysql
You can use the "IN" to return the options you need. Would look like this: SELECT Livro, Autor FROM Biblioteca WHERE Genero IN('Romance','Terror'); Above, records will be returned where "Genero"…
mysqlanswered Gato de Schrödinger 2,367 -
0
votes1
answer105
viewsQ: "Random" number being generated along with md5 hash
I am developing an application in Laravel and at a certain moment I need to generate a value in MD5 to assign to a field in the database. The problem is that when generating this hash of MD5, a…
-
1
votes3
answers80
viewsA: Know the total values in the php array
No need to quote numbers. If used, they will be treated as string. $total = array(6.00,7.00,9.5,10,5.5,7.75,6.5,9); $contador = 0; foreach ($total as $item) { if($item < 7) { $contador++; } }…
phpanswered Gato de Schrödinger 2,367 -
0
votes4
answers951
viewsA: How to make a "read more" and a "read less" button in a text that comes dynamically from the database with Pure Javascript?
Following the answer and tips in the comments of Wallace Maxters, I was able to adapt my code and make it functional, based only on JS (with a minimum of PHP). I’m leaving my code only to help…
-
3
votes4
answers951
viewsQ: How to make a "read more" and a "read less" button in a text that comes dynamically from the database with Pure Javascript?
I would like to make a "read more" and "read less" button with Pure Javascript (no jQuery). However, this text comes dynamically from the database and I use a PHP foreach to fill the Divs with these…
-
1
votes1
answer77
viewsQ: How to pass a null value in the update() method of clancats hydrahon?
I need to pass a null value to a column (date type) of the mysql database, according to the following code: $birthdate = null; User::update() ->set('name', $name) ->set('email', $email)…
phpasked Gato de Schrödinger 2,367 -
0
votes1
answer37
viewsA: How to pass information in bindvalue with two or more information stored in the variable?
I was going through a similar situation to that question. I was wanting to take the emails of users with the ids that were in that '$array'. I solved it the way below: $array = [1,5,9]; $ids =…
-
0
votes1
answer105
viewsA: How do I subquery Laravel based on this information?
I was able to solve using the raw class DB. I imported the class at the top of the file like this: use Illuminate Support Facades DB; //Calling class DB And the code of the method went like this:…
laravelanswered Gato de Schrödinger 2,367 -
-1
votes1
answer105
viewsQ: How do I subquery Laravel based on this information?
I have the tables: Notifications: users: ... And I got the following code that’s in my controller: public function allRelations($internalClientId) { $internalClient =…
laravelasked Gato de Schrödinger 2,367 -
0
votes2
answers66
viewsA: How to search for all associations in a relationship tree in Laravel?
I tried to do with with. But the whole chain of relationships returned. Behold: public function allRelations($internalClientId) { $internalClients =…
-
0
votes2
answers66
viewsQ: How to search for all associations in a relationship tree in Laravel?
I’m having a dilemma. I have tables that relate, like,: internal_clients->Subsidiaries->departments->job_titles->users I also have their respective models. My question is: How do I get…
-
-1
votes1
answer129
viewsQ: How to insert data into a table that has multiple Foreign key and relates to other 4 tables using Laravel with Eloquent?
I have a table that has 4 foreign Keys and relates to 4 other tables. I would like to know how I would insert all the records, coming in Request, in this table, including your Foreign key. I’m a…
laravelasked Gato de Schrödinger 2,367 -
0
votes2
answers78
viewsA: Display different messages on a Javascript site
Talk to me, brother. This code is just to give you a light. I think based on it, you get what you want. Adapt to your code. If you want, optionally, you can add a table to display the result…
-
2
votes7
answers7167
viewsA: How to receive the CPF number and format to be without the dots and dash(Input Mask )
Just to supplement the previous answers. If you want to take both at once (dot and dash). My answer is with Pure JS. let botao = document.querySelector("#botao"); botao.onclick = function() { let…
-
1
votes1
answer52
viewsA: How to call a connection within a function?
By declaring the function this way you are saying that it will receive a parameter. Declaring the function. function ExibirCarrinho($parametro) { $exibirCarrinho = "SELECT * FROM carrinho";…
-
0
votes3
answers362
viewsA: How to insert a new key associated with a new value at the end of a PHP Multidimensional Array
There are several ways to do this. I’ll leave two examples here: First example: <?php $matriz = array( array("id" => 1877,"type_id" => 4,"service_id" => 1100), array("id" =>…
-
4
votes1
answer178
viewsA: How to access the textarea, grab its value and display it?
Help yourself, my brother. let textarea = document.querySelector("#txtar"); let botao = document.querySelector("#botao"); botao.onclick = function() { console.log(textarea.value); } <textarea…
-
1
votes1
answer68
viewsQ: How to add a column in the database where its value is equal to the current year + the table id field?
I have a table called "users" in the database. See below the table structure: I would like to enter a field called "matricula" varchar (50) there after the "id" field. However I would like this…
mysqlasked Gato de Schrödinger 2,367 -
0
votes1
answer109
viewsA: make SQL query return in an organized way
Brother, you are trying to store and display the data resulting from the query in String form. I think the ideal would be for you to store and display in array form to be more organized both for you…
-
1
votes4
answers1899
viewsA: Insert comma automatically while typing
I always use this little function that I will leave here in the reply. It dispenses with the use of plugins and is done with a simple jQuery. Serves for CPF, CNPJ and other various types of…
-
3
votes3
answers84
viewsA: How to display a person’s name within the title="" tag label that is in a <input> in a PHP form?
See if that answer solves your problem: We added an event onchange to your select(This event happens when we change the select (option) option) The "this" means that you will take that element that…
-
3
votes1
answer141
viewsA: How do I display a person’s name in the onclick message="Alert()"?
Brothão, I think that to do this with Javascript is better and easier than to do with PHP. By clicking the button we call the function displayName(). When the function displayName() is called, it…
-
1
votes2
answers160
viewsQ: What strpos() returns when the searched value is not found?
I have a code that is causing me a doubt when returning the method strpos() of PHP. See what is returned when the value sought is found: $string = "vermelho"; $result = strpos($string, "vermelho");…
phpasked Gato de Schrödinger 2,367 -
1
votes1
answer252
viewsA: How do I click a button and remove the table row via javascript?
Speak up, Caião. See if it helps you. function removerElemento(elementoClicado) { elementoClicado.closest("tr").remove(); } <table border="2" id="tabela"> <thead> <tr…
javascriptanswered Gato de Schrödinger 2,367 -
0
votes1
answer185
viewsA: How to capture data from a SELECT in javascript?
Help yourself, my brother. function calcular() { var opcao = document.getElementById('opcao').value; switch (opcao) { case '6': alert('voce escolheu 6'); break; } } <legend>Selecione o modelo…
-
0
votes1
answer37
viewsA: Problems to execute query (SELECT with INNER JOIN) that uses data from an HTML form
I did something that doesn’t seem to be the best way, but it was something that solved my problem. In my view it solved in an improbable and wrong way (but solved). I had to take out the binds and…
-
0
votes1
answer37
viewsQ: Problems to execute query (SELECT with INNER JOIN) that uses data from an HTML form
I have the following code below: public function listarClientesBuscadosDoForm() { try { $c = new Conexao(); $db = $c->conectar(); $query = "SELECT a.cod, a.razao_social, a.cnpj,…
-
1
votes3
answers33
viewsA: Calculate Two-digit Average reported by the user. However, the result is always zero
Come on! //Criação da função que receberá como parâmetros os valores dos seus botões function media(num1, num2) { let mediaCalculada = (num1 + num2) / 2; document.write(" <br> media:",…
javascriptanswered Gato de Schrödinger 2,367 -
6
votes2
answers967
viewsQ: What happens to a SESSION when it expires in PHP or refreshes the page?
What happens when Session time expires ? (This time is usually 24 minutes by default). Example: When logging in we set the credentials of a particular user on $_SESSION, with the data resulting from…
-
2
votes3
answers596
viewsA: What is the difference between DOM event handlers?
Complementing the responses of the boys and to help people who want to see the difference in execution, I will leave two practical examples that shows the difference between the onclick() and the…
-
0
votes2
answers65
viewsA: Events in Javascript
The main difference is that with the onclick() you can only associate a function as callback of the event. Already with the addeventlistener() you can use as many functions as you want them to be…
-
0
votes1
answer51
viewsA: After ordering the code to return an Alert if the input values are reset, when pressing the button the page hangs
In the if you use ini.value.length. This is not possible for inputs as inputs do not have length. The elements are the ones you assigned in the variables in document.getElementByID, that cannot be…
javascriptanswered Gato de Schrödinger 2,367 -
0
votes1
answer60
viewsA: Delete button does not work!
Follow the answer code: <div class="col-md-8"> <a href="excluirConta.php?id=<?php echo $_SESSION['id'];?>" class="btn btn-danger">Excluir Conta</a> </div> Filing…
-
2
votes2
answers2640
viewsA: Take data attribute value and apply as text in another html element
It’s funny, I usually get data-Attributes in another way. I think there are several ways to do this action. It’s then as an alternative. See how I do: $("select#teste").change(function(e) {…
-
1
votes2
answers692
viewsA: Problems with accentuation in Mysql
An alternative solution is that if we are using PDO, the fourth parameter at the time of instantiating the PDO class is super important for special character situations. //Fazemos a conexão com…
-
0
votes2
answers2045
viewsA: PHP accent problem, Mysql
An alternative way is that if we’re using PDO, the fourth parameter at the time of instantiating the PDO class is super important for special character situations. //Fazemos a conexão com nosso…
-
3
votes1
answer51
viewsQ: How would I let this expression of mine beyond the character - (less) be accepted the + (more) as well?
I have an expression on a input, using pattern, that has some rules, among them: Accept uppercase letters, lowercase, minimum of 5 characters, do not accept special characters (only accept the -).…
-
1
votes1
answer397
viewsA: Query mysql username in php
The user did not put the PHP code that performs the query in the database and returns the data that populates the SESSIONS. However, talking in chat, he informed me the code (that he had done) and I…
-
1
votes1
answer162
viewsA: PHPMAILER library sending duplicate emails
I solved the problem using the PHPMAILER method, ClearAddresses(). I have been reading and I saw that this method is used to delete the destination addresses that were previously passed in the…
-
-2
votes1
answer162
viewsQ: PHPMAILER library sending duplicate emails
I have a PHP code that sends data to Phpmailer (data resulting from a query in the database). The problem is that when Phpmailer fires the email, it arrives duplicated in the inbox of who should…
-
1
votes1
answer109
viewsA: How to list JSON data in a div using jquery?
Buddy, the code is a bit plastered. You can do better (more dynamic). But take a look and see if it suits you. Any doubt, you warn in the comment, I try to improve something. You could adapt better…
-
5
votes1
answer67
viewsA: Add class using Jquery in a specific form?
See if it helps you: $(document).on("click", ".botao-curtir", function(e) { //e.preventDefault(); $(this).addClass('red'); }); <form method="post" id="like"> <div class="form-group">…
-
1
votes0
answers54
viewsQ: PHPEXCEL generating Notice: Undefined offset: 0 in Excel5.php file
I am trying to use Phpexcel to try to import . xls and convert them to php, to add your information in the database. However, when I import a file . xls, I get the following Notice: Undefined…