Posts by João Pedro Henrique • 1,172 points
49 posts
-
1
votes1
answer616
viewsA: mysqli_num_rows() expects Parameter 1 to be mysqli_result, bool
The problem is that there is an error in your query. According to PHP documentation, when using mysqli_query: Returns FALSE on Failure. For Successful SELECT, SHOW, DESCRIBE or EXPLAIN queries…
phpanswered João Pedro Henrique 1,172 -
1
votes1
answer33
viewsA: Path with Laravel URL parameters
It’s a typo. Note that in the method declaration in the controller you have: $caregoria_id instead of $categoria_id
-
1
votes2
answers118
viewsA: insert into an imput table data
It turns out that there are several elements with the repeated ID, and the document.getElementById will access the first element he finds with the past id. One output is to make this id dynamic,…
-
0
votes1
answer85
viewsA: Push array only works inside callback
This happens because of problems with the asynchronous character of the callback. In this case, you should use Names together with async/await: async countDoucments() { const numeroDeDocumentos =…
-
0
votes2
answers50
viewsA: Would you like to know how to receive the value of my select by clicking on an option with pure javascript?
Use the Javascript onchange event. So, every time a change occurs in select, the function alteraValor will be called, in which case will print on the console the recovered value. function…
-
0
votes1
answer27
viewsA: Undefined index php post error
The problem is that you are trying to look for an index that does not exist in the POST. This generates an error of undefined index. To avoid this, perform a check before assigning variables using…
-
1
votes2
answers91
viewsA: Display all elements on the screen
First of all, how André scored, using the function reduce will not allow you to iterate through this array in the desired way. We will use forEach. Another point is that you are overwriting the body…
javascriptanswered João Pedro Henrique 1,172 -
1
votes1
answer26
viewsA: Add value to a reference value determined each different day for the whole year
The example below calculates the difference in days between a predetermined date and the current date, and after that, adds up the values as you wished. <?php // Constantes $DATA_INICIAL =…
-
1
votes1
answer102
viewsA: Select in 2 tables
Hello, Martins. No need to use row_count or anything, you can use the SQL functions itself, such as COUNT a GROUP BY and make a relationship between the two tables using LEFT JOIN. This way, you can…
-
1
votes1
answer58
viewsA: Read and print a 21-digit sequence
One thing to note is that you are trying to assign the value of an integer a char, using the function getchar. Instead, use the scanf. Example #include <stdio.h> void testa_nib() { int i = 0,…
canswered João Pedro Henrique 1,172 -
1
votes1
answer144
viewsA: filter routes by a prop in the meta. Vue.js
Before iterating over the routes, run a filter in the route array. So you can have an array only with the routes you want. In the computed, do: computed: { routes() { return…
-
3
votes3
answers60
viewsA: Javascript - Show function result in class
Instead of using class, prefer to use id. Because they are unique, they avoid possible side-effectcts in your code. It looks like this: function getData(){ var today = new Date(); var dd =…
-
0
votes1
answer42
viewsA: Tools js, CSS and others
It is important to keep in mind the usefulness of each of these tools during development. Webpack, for example, is a tool that allows the generation of one or more Unboundles according to the…
-
0
votes3
answers50
viewsA: Count data from a table to sum
Hello, Natan. For this, you will need to use relationship between tables and SQL data grouping. Suppose we have the table ordens with the following structure: `ordens` nome_do_profissional | servico…
-
0
votes1
answer56
viewsA: Populate input with object value via the key dynamically
Hello, Silvio. You can do: var objeto = { 10: 0.9997, 11: 0.9996, 12: 0.9995 } function mostrarValor(valor) { var caixaValor = document.getElementById("caixa-valor") if(typeof objeto[valor] !==…
-
0
votes1
answer32
viewsA: How do I execute a main() function without affecting the other of another script?
One way out is to not pollute the global namespace by encapsulating the functions of each file into a prototype. In this case, the Arquivo1becomes: Arquivo1.js function Arquivo1() { this.main =…
-
0
votes1
answer16
viewsA: Update records by blocks
You can use the method COUNT MYSQL. It allows you to count the number of records in a table quickly. With the amount of records and the amount of records per block on hand, the latter is a constant,…
-
4
votes3
answers179
viewsA: Make an input receive a value less than another
Use the attribute [min][1]. <input type="number" name="total" value="25" required> <input type="number" name="valor-em-dinheiro" class="form-control text-right" required min="25">…
-
0
votes2
answers46
viewsA: How do I print the smallest height ever read?
Now that I see you’ve created another thread... you can do: #include <stdio.h> int main () { int sexo = 1; float altura, maior = 0, menor; int tm = 0, tf = 0, sm = 0, sf =0; int iteracao = 1;…
canswered João Pedro Henrique 1,172 -
2
votes1
answer31
viewsA: How do I display the highest height ever read on the screen?
You need to declare the variable initially maior as the value 0, and after that go checking whether each user input is greater than the previously stored value. If it is, store the new value in the…
canswered João Pedro Henrique 1,172 -
1
votes1
answer102
viewsA: Insert Command Line in typescript
To execute a command on the terminal using Typescript, you can use the function exec from the Nodejs native library child_process. With her, you can do: import { exec } from 'child_process'…
-
0
votes1
answer166
viewsA: Change layout color
Exactly, you can use JS using the attribute .style to change the CSS of a div. Take this example #quadrado { background: #000; width: 100px; height: 100px; } <div id='quadrado'></div>…
-
4
votes1
answer89
viewsA: How to read this JSON correctly? MSSQL and Node
To have an array in which each element is one IdPapel, you need to access the array of users returned by the query to the Database. Assuming the answer is stored in the variable result, we can do:…
-
0
votes1
answer1151
viewsA: Creation of product registration with javascript
Matthew, One of the problems with your code is that it will call the AJAX request regardless of whether the form is valid or not. The way things are, you only do the validation after you send the…
-
0
votes1
answer141
viewsA: Filter dates in array
Using pure JS, you can use a combination of filter and some methods of the object Date. I understood that you want to filter the results by month and year, so it would be like this: // Recebe o…
-
1
votes1
answer160
viewsA: Where in string list does not work Cloud Firestore
How’s the Firebase documentation, Using the data like this doesn’t allow you to do what you want. They do, however, propose an alternative to make it work. You can structure your data as follows: //…
-
1
votes1
answer335
viewsA: How to use async and await in Nodejs
The error is that you do not need to touch openConnection. To use async/await, the called function must return a Promise. See the reference of Mozilla. So your code should stay: openConection(req,…
-
5
votes2
answers2641
viewsA: Find lower vector value recursively
What is happening is that you are zeroing the value of m with each iteration, soon will always return m=0. An alternative is to m a function parameter, passed every iteration. It would look like…
canswered João Pedro Henrique 1,172 -
3
votes2
answers71
viewsA: I can’t seem to register a person’s name in my calendar
The error is in how you structured the data in the structure. nome should be a matrix, not a vector. Making: typedef struct { int numero[MAX]; char nome[MAX][MAX]; int tam; } AGENDA; In your code…
-
2
votes1
answer491
viewsA: Cors error accessing Api
This is a protection that browsers have, preventing a customer at another address to make a direct request on some site, unless it authorizes external traffic. In these situations, it is worth…
-
1
votes1
answer72
viewsA: Javascript - Compare input field to mongodb field
Assuming you’re using Mongoose and Express, in your controller you can do: function findOneInput(req, res) { Model.findOne({ field: req.query.input }, function (error, input) { // Trata erro…
-
0
votes1
answer75
viewsA: How do I style this code with css and html? Blogger
You can use CSS. Example: #postList12 { /*Lista*/ background: #000; /* Cor de fundo */ font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; /* Fonte */ } #postList12 li a { /*Link*/ color:…
-
3
votes1
answer293
viewsA: Add document subdocuments - Mongoose
Use the operator $push: Collection.findByIdAndUpdate(id, { $push: {viagem: OBJETO } }, options, callback)…
-
0
votes1
answer980
viewsA: How to calculate the Quantity of the even numbers of this vector?
Check that the rest of the division of each number by 2 is equal to 0. If it is, add to a counter. <?php // Porcentagem de pares $array = Array(1, 2, 3, 4, 5, 6); $contador = 0; // Responsavel…
phpanswered João Pedro Henrique 1,172 -
7
votes1
answer137
viewsA: Destructuring of Arrays
It’s called Allocation via de-structuring. In this case, the code snippet declares the Carol variable, which will receive the second position of the array that was passed, so the notation [, Carol].…
javascriptanswered João Pedro Henrique 1,172 -
1
votes1
answer375
viewsA: Convert PHP functions to Javascript
Just change the function processaValor: $basicoUS_mensal=processaValor("url_aqui"); function processaValor($url) { $result = file_get_contents($url); $aspas = strpos($result, "'"); $valor =…
-
5
votes2
answers573
viewsA: How to access an object by a variable?
You can try using window[variavel]. Would look like this var tipoUm = { 1: 1.10, 2: 2.50, }; var tipoDois = { 1: 2.20, 2: 4.70, }; $(".tipo").on('change', function(){ var tipo = $(this).data("id");…
-
2
votes2
answers74
viewsA: Motrar value of file_get_contents but only what is in quotes
Mix replace and strpos. It goes something like this: <? $valor_mensal=processaValor("https://dominio.com/feeds/productsinfo.php?pid=3&get=price&billingcycle=monthly");…
phpanswered João Pedro Henrique 1,172 -
1
votes3
answers69
viewsA: Add items to the beginning of a vector without affecting existing values
Using what you said, we should do: #include <stdio.h> #define TAMANHO_VETOR 30 int main () { int vetor[TAMANHO_VETOR], i; // Recebe as primeiras posicoes for (i = 0; i < 15; i++) { printf…
-
3
votes2
answers2891
viewsA: Make page zoom default
Yes, and you don’t even need JS. Using HTML5: <meta name="viewport" content="width=device-width, initial-scale=1.0"> The initial-Scale controls the page’s initial zoom. 1.0 is 100%, 0.75 is…
-
2
votes2
answers205
viewsA: Best way to generate a dynamically read with pure javascript
You can use the Template Strings. An example, using a very simple list: const dadosJSON = [ { nome: 'StackOverflow EN', url: 'https://stackoverflow.com/' }, { nome: 'StackOverflow PT', url: '/' }, {…
javascriptanswered João Pedro Henrique 1,172 -
2
votes2
answers313
viewsA: Keep the value of a countdown counter with javascript
A solution may be to use the localStorage to save the time of the counter each update. It is simpler than cookies. As you don’t want the direct answer, I recommend you take a look at the…
-
1
votes1
answer105
viewsA: How to display a message after deleting a record using php?
Yes, you can do this using AJAX. The code looks something like this: jQuery.ajax({ type: "POST", url: URL-DA-SUA-REQUISICAO, data: DADOS-DA-SUA-REQUISICAO, success: function sucesso(dados) {…
-
0
votes1
answer965
viewsA: Send form and post message of "success" on your own page, and after clicking on Submit appear another button
To show the message in a floating box, you must be talking about creating a snackbar. In the code below, I added the snackbar and download button. The download button loads the page as hidden, and…
-
0
votes1
answer258
viewsA: Restful API with Nodejs and Mysql with Multiple Columns (I want to return json levels)
One idea is to use: // Exemplo de resposta do MYSQL const resultados = [ { coluna1: 'AAAAA', coluna2: 'XXXXX' },{ coluna1: 'AAAAA', coluna2: 'YYYYY' },{ coluna1: 'BBBBB', coluna2: 'ZZZZZ' }, ] //…
-
0
votes2
answers286
viewsA: How to reverse the animation of a Modal?
With the fadeOut animation, you need to change the class the HTML element is assigned to, from fadein to fadeOut. For this you can use javascript. function mudarClasse() {…
-
1
votes2
answers80
viewsA: How to know which elements are before and after a given element in the array?
You can use the functions filter and index. It goes something like this: const array = [1,"a",3] const arrayReduzida = array.filter(function (value, index, array) { return index <…
javascriptanswered João Pedro Henrique 1,172 -
1
votes1
answer146
viewsA: print variable Java script within HTML
From what you wrote, just make a small change: <script type="text/javascript"> $(".j_requerimento").click(function(){ var click = 1;…
-
1
votes2
answers224
viewsQ: MYSQL NOT IN array php
Hello, gentlemen I am working on a project for a hobby I have and am having a hard time with the MYSQL part. I have an array that comes from the API and is decoded and inserts some data of the…
phpasked João Pedro Henrique 1,172