Posts by Thiago Magalhães • 1,912 points
59 posts
-
1
votes3
answers329
viewsA: How to return the number of arguments and sum the values of the arguments in a javascript function
Just use the property length function. See the following example: function f1(a) { console.log("aqui tem 1") } function f2(a, b) { console.log("aqui vai ter 2") } function f3(a, b, c, d) {…
javascriptanswered Thiago Magalhães 1,912 -
2
votes1
answer49
viewsA: Purge invalid data before creating a Foreign Key (FK)
Just make a DELETE in Tabela C, checking whether the id that are being used in the table C no longer exists in the A or in the B. DELETE FROM Tabela C WHERE idTabelaA NOT IN (SELECT id FROM TabelaA)…
-
2
votes1
answer52
viewsA: Function in C does not return the number squared that the user computed
You are passing the number by parameter: sqr(num); But its function sqr does not have the parameter, it is like this: void sqr () { ... } And it should be like this: void sqr (int x) { ... } The…
canswered Thiago Magalhães 1,912 -
1
votes1
answer50
viewsA: How do I show the results of a certain year?
You must use the function YEAR to take only the year of the date and compare with the desired value. The problem is in the condition of sql: ... WHERE data = 2019 The right thing would be: ... WHERE…
-
1
votes1
answer2492
viewsA: Sum of numbers in Javascript
Change parseInt(num) parseInt(soma) soma = num while (num != 0 || num > 50) { num = prompt("Digite um número abaixo de 50 ou 0 para finalizar:"); soma = soma + num if (num % 2 == 0) contPar =…
javascriptanswered Thiago Magalhães 1,912 -
2
votes2
answers129
viewsA: Error in viewing multiple Google Maps markers PHP, JS, HTML
<?php echo' <script> function myMap() { var myCenter = new google.maps.LatLng('.$users_dumps_map[$dump['container_id']].'); var mapCanvas = document.getElementById("map"); var mapOptions =…
-
2
votes1
answer345
viewsA: How to enter the generated id in the Insert as a foreign key from another table?
In the PHP there is a specific function to take the last inserted ID. Mysqli If used MySQLi can use procedural mode or OO mode. Procedural mode mysqli_insert_id($conexao); Oo mode…
-
1
votes1
answer109
viewsA: Display hexadecimal color with php coming from Mysql
Try it like this: <?php foreach($ResCor as $ProdCor ) { ?> <a href="javascript:void(0);"> <div style="background-color: <?= $ProdCor->Cor ?>; width: 100px; height:…
phpanswered Thiago Magalhães 1,912 -
2
votes1
answer31
viewsA: Count mysql records in X Y format to display in Wizard style form
Try this way: ... $query_questionario = mysqli_query($conn, $sql_questionario); $total = $query_questionario->num_rows; $question = 0; while ($dados_questionario =…
-
2
votes2
answers559
viewsA: Grouping an array’s value in PHP
Having a variable with the array desired, calling it $input, you could do it this way: $arr = array(); foreach($input as $value) $arr[$value->nomreg][] = isset($value->valven) ?…
-
7
votes3
answers810
viewsA: php Session - destroy all Sessions and keep only one active
You could create a variable temporarily to receive the session variable value, destroy all and then create only the session variable you want. $auxiliar = $_SESSION['session4']; session_unset();…
-
3
votes3
answers41
viewsA: Do not show element that has a certain value
SELECT usuario.id AS usuarioId FROM usuario LEFT JOIN usuario_gerenciamento ON usuario.id = usuario_gerenciamento.usuario_id WHERE usuario.id NOT IN (SELECT usuario_id FROM…
mysqlanswered Thiago Magalhães 1,912 -
2
votes2
answers71
viewsA: Variable value in PHP
It is not possible to create variables by defining their name as if it were a string and the concatenation of string in PHP it’s not like this: for($i = 0; $i <= $qtdProd ; $i++){ $a25Item i =…
-
1
votes1
answer32
viewsA: My url does not receive the id parameter in the display? id=. Why?
In the part where you define the link: <a href="https://localhost/estoque/public/produtos/mostra?id=<?php $p->id ?>"><span class="glyphicon…
-
2
votes2
answers149
viewsA: Disable case sensitive only in a comparison
Not directly, but can be used a function that performs the insensitive comparison, such as the strcasecmp. As I said, you can also manipulate strings to make the manipulation, using strtoupper and…
phpanswered Thiago Magalhães 1,912 -
2
votes1
answer271
viewsA: Problems traversing nested json
Every time you’re riding one array to add to variable $aux, you are assigning the value of that moment and not adding to the vector. You’re doing it like this: $aux = array(...); And you should do…
-
2
votes2
answers901
viewsA: How to use Multiple select in PHP form to query in MYSQL
Change the name of select that way: <input ... name="bairro[]" ... > This way you will receive the $_GET["bairro"] as an array with data from form.…
-
0
votes2
answers199
viewsA: Multiline textbox printing last item only
The problem is that in Text of textBox, for each line it reads you are assigning the value, replacing the value it had previously. textBox1.Text = leitor; The correct one would be to concatenate,…
-
0
votes1
answer1287
viewsA: How to receive data from an html form with PHP
You are using the name of the inputs as if they were matrices. Do you really need this? Will you change the data of more than one user? If you don’t need to, try to simplify the name of the inputs.…
-
2
votes2
answers295
viewsA: Sum json object property
Your code has two small errors. See: var mult = data.qtd++; The way it is, how you’re using post increment operator, you’re basically doing this: var mult = data.qtd; data.qtd++; Hence the value of…
-
1
votes2
answers215
viewsA: Problem inserting data into a table containing foreign keys
The way you did: SELECT id_evento,nome,numero,cidade,dia,horario FROM evento,cliente WHERE id_evento = 1; It will concatenate the table tuple evento with id_evento = 1 with each of the table’s…
-
0
votes2
answers40
viewsA: Select does not load the options directly
Try it this way: echo "<option value='", $cd_cobr , "' selected='yes'>", $ds_cobr, "</option>";
-
7
votes1
answer75
viewsA: C# float++ and float-
What the post increment operator does? As explained by @Jefferson Quesado. When you use for example index++ you are calling a function that will create an associated copy. Explaining what happened…
c#answered Thiago Magalhães 1,912 -
1
votes3
answers160
viewsQ: Use string to reference variable
I wish to move on to the function execSQL the name of the variable I want to use in base.consulta() and from the string SQL, directly pass the variable to the function base.consulta(), that is, pass…
-
1
votes1
answer330
viewsA: Count element amount of a page array
$array = [ ["appid" => 291550,"name" => "Brawlhalla"], ["appid" => 000000,"name" => "Teste"], ]; $count = 0; foreach($array as $arr) if (array_key_exists("appid", $arr)) $count++; echo…
phpanswered Thiago Magalhães 1,912 -
2
votes1
answer46
viewsA: Count database records without repeating
Do it this way: SELECT t.profissao, COUNT(t.profissao) as total FROM tabela t GROUP BY t.profissao In the SELECT place COUNT(t.profissao), grouping by the same field, ie, GROUP BY t.profissao. This…
-
2
votes1
answer287
viewsA: TAKE DATA FROM FORM JS
Jquery // pega todos os input var $inputs = $('form :input'); var values = {}; // percorre os inputs $inputs.each(function() { var name = this.name; // nome do input var value = $(this).val(); //…
-
2
votes1
answer89
viewsA: Smallest element of a sub-list, in a list
Code k = 0 for (i, sublista) in enumerate(L): if sublista[2] < L[k][2]: k = i # indice da lista (L) que contem o menor L[][3] print(k) Explanation The variable k will store the list index L which…
-
1
votes2
answers499
viewsA: How to redirect to a url using url parameters
Code $().ready(function () { var url = new URL(window.location); var sub = url.searchParams.get("sub"); var red = url.searchParams.get("red"); setTimeout(redirecionar, 5000); if(sub == 1) {…
-
3
votes1
answer329
viewsA: Insert two commands (INSERT and UPDATE) into the same instruction in Sqlite, via R Language
Put the two instructions to be executed in the same query probably possible, however this will not guarantee that the two operations will be carried out. For even if it is sent in the same query, it…
-
1
votes1
answer10
viewsA: Go to a given link according to Radio Box with PHP
Solution HTML <button type="button" class="btn btn-primary" id="getRadio">Continuar</button> JS $().ready(function () { $("#getRadio").click(function () { if…
-
1
votes1
answer80
viewsA: How to create a . click() limiter in JS?
Solution See an example of how it could be done: $().ready(function() { var limit = 0 $("td").click(function () { if (limit++ < 2) { this.style.color = "#FFF"; this.style.backgroundColor =…
-
5
votes2
answers332
viewsA: Mysql - Select between 2 tables with "String" field
Best way SELECT * FROM tabela1 t1 WHERE NOT EXISTS (SELECT t2.nome FROM tabela2 t2 where t1.nome=t2.nome)
-
2
votes1
answer38
viewsA: Relate disciplines and students of a pre-registration system
Could be created a class called Turma, formed by an attribute Disciplina and a list of Estudantes. The Curso would have a list of Turmas. To know in which Disciplinas the Estudante is registered,…
-
3
votes2
answers880
viewsA: How to check if the url is true
You may be checking if your strings belong to a pattern using regex. Follow an example of a er (regular expression) and how would your use: var re = new…
-
1
votes2
answers29
viewsA: Select database items that contain something similar to the contents of an array
You can mount your query in two ways. First Form $query = "SELECT * FROM table WHERE col IN ("; foreach ($array as $key => $value) $query .= "'" . $value . "', "; $query = substr($query, 0,…
-
0
votes2
answers113
viewsA: How could I improve this SQL query query with sub querys?
@Ivan, I saw that you changed your table by adding a new table and changing the field of others. But like your data from INSERT are not updated, I could not test with the new structure. But based on…
-
2
votes2
answers1393
viewsA: Loop problem with switch case
Add getchar(); After scanf("%c", &opc); When you choose an option that is not read and key ENTER. He perform the operation you chose and understands the ENTER that you gave as an option you…
-
0
votes1
answer281
viewsA: Select files from a directory by name
If all the files are in the same folder, your mistake is to list the files without doing a check of the file by the user ID. You can resolve by placing a check inside the while as follows: // a…
-
2
votes1
answer104
viewsA: create a select within while
Try it this way: $tabela1 .= '<td> <select data-qtd3="Fornecedor" style="width:106px" name="Fornecedor[]" id="Fornecedor">'; $sql = "SELECT * FROM Fornecedor ORDER BY Fornecedor ASC";…
-
4
votes1
answer129
viewsA: Join Mysql tables
Reason for the error: With the query that you did, the condition of taking the data from the two tables is B.HORA = A.HORA. On the table medicacao the values of horas are closed values, such as…
-
2
votes1
answer186
viewsA: How to Debug a Windows Service?
I recently also made a service for Windows in C# and used the topshelf. It allows you to develop the service as a console aplication and with that you can debug normally. When your service is ready,…
-
0
votes2
answers47
viewsA: Alert only appear 1x inside a for
Try to do it this way: clienteController = new ClienteController(session); int contador = 0; List<ContaCorrenteModel> contaCorrenteModelList = new ArrayList<ContaCorrenteModel>();…
-
1
votes1
answer54
viewsA: Import xml data field
Try to do it this way: // criar date time 2018-07-24 00:00:00.000 DateTime dt = new DateTime(2018, 7, 24, 00, 00, 00, 000); String.Format("{0:dd/MM/yyyy}", dt); You can see more about formatting…
c#answered Thiago Magalhães 1,912 -
1
votes2
answers102
viewsA: How to take the last inserted values from two tables, and sort them by the last access?
Try it this way, buddy: SELECT * FROM exemplo2 e2 INNER JOIN ( SELECT exemplo1.id_acesso, exemplo1.cod_mobilibus, MAX(exemplo1.dt_acesso) dt_acesso FROM exemplo1 GROUP BY exemplo1.cod_mobilibus ) e1…
-
1
votes2
answers47
viewsA: Total Subrecords - Mysql
Based on its assumption, the query would look that way: SELECT tabela_1.id, tabela_1.loja, tabela_1.data, COUNT(tabela_2.id_2) as quant_tab_2 FROM tabela_1 LEFT JOIN tabela_2 ON (tabela_1.id =…
-
2
votes1
answer60
viewsA: How to make condition with msql number
FORM EXPLAINED Simple, just do a validation before the UPDATE, about the value informed by the user. More or less in this way: Start of your PHP code placed in the question $id = $_POST['id'];…
-
1
votes2
answers503
viewsA: Value of a text variable to select a Select item in javascript
Thus: JS + Jquery Code $(document).ready(function() { var texto = "Mercedes"; var exemplo = $("#test").find("option:contains('" + texto + "')"); exemplo.attr('selected', 'selected'); }); Excerpt…
-
1
votes2
answers648
viewsA: how to access the class array with jQuery? Take the second class of an element
Thus: classeDesejada = $('li.card').children().find('i:eq(0)'); You pass in the :eq() the desired position. See more about the eq-selector in the documentation of JQuery.…
-
1
votes1
answer53
viewsA: Extract contents from <script>
<?php // passando o json diretamente para poder testar $data =…
phpanswered Thiago Magalhães 1,912