Posts by arllondias • 2,492 points
145 posts
-
-1
votes2
answers147
viewsA: Recover dynamic input file via php
From what I noticed missed the index in the picture field, try to add: for($i = 0; $i < $total; $i++) { printf("Título : %s <br />", $input_titulo[$i]); printf("Descrição : %s <br…
phpanswered arllondias 2,492 -
1
votes1
answer291
viewsA: Calculation function with dynamic cursor
As far as I know Mysql has some restrictions with DECLARE, You cannot DECLARE after some operations, so work this way, Declare the 2 cursors and work with the IF’s checking where to use cursor 1 or…
mysqlanswered arllondias 2,492 -
2
votes1
answer1275
viewsA: Print table with ajax and php
In my case, I’m with a version where the error that the mysql function is deprecated, just add this line at the beginning of your file pulls.php: ini_set('display_errors', 0); Although it’s not…
-
0
votes1
answer453
viewsA: How do I make a cell to be a button in a table?
From what I understand, that’s more or less what you need, just implement in your need. <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>…
-
0
votes2
answers428
viewsA: How to make a query that brings only the count of an uninterrupted sequence?
I think the query would look something like this, working with variables: SET @total = 0; SELECT MAX(total) FROM( SELECT @total:=@total+1 AS total, IFNULL(valor, @total:=0) as aux, valor, ano FROM…
-
1
votes2
answers728
viewsA: How to search for something in 100% of Mysql database
In this Procedure it searches in all fields that are not numerical given content, first parameter you pass what you want to search and second the name of the database, it will return all found…
mysqlanswered arllondias 2,492 -
2
votes2
answers1321
viewsA: String Comparison in jQuery
You have to change the || for &&. As it stands, the second condition is true, returning the alert. Not to enter the alert, both conditions must be false (&&), and not a or another…
-
0
votes3
answers1470
viewsA: Hide DIV when loading the tab according to select
Execute $('#TipodeDocumento_6').trigger('change'); When the document is already loaded
-
-1
votes3
answers52
viewsA: For JS code to scan the console
I made some changes and added jquery to your code, test to see if this is what you need. <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"…
-
1
votes2
answers74
viewsA: Non-specific search filter
You can solve this way by breaking the sql into parts: $servico = isset($_POST['servico']) ? $_POST['servico'] : null; $estado = isset($_POST['estado']) ? $_POST['estado'] : null; $cidade =…
-
1
votes1
answer427
viewsA: Create Dropdown list from another Dropdown with PHP
Just try to make this change exchange this code for your checkerList(): <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <form name="listas" method="GET"…
-
1
votes2
answers1469
viewsA: 2 INPUT in 1 field only
You can do with javascript or concatenate the two fields in your backend in case I am doing with javascript using jquery and an Hidden input that will receive the concatenated value: <script…
-
3
votes3
answers4262
viewsA: How do I get the difference between dates on business days in Mysql?
I went through a problem like this once, we solved it like this: Table of dias_uteis: CREATE TABLE dias_uteis( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, data_util DATE ); I made a procedure where…
mysqlanswered arllondias 2,492 -
1
votes1
answer142
viewsA: Insert in Mariadb giving timeout
Make sure your connection is not running any process that may be affecting your database: SHOW FULL PROCESSLIST; You can kill the process using the command: KILL [ID_PROCESSO] A transaction started…
-
0
votes2
answers621
viewsA: I am unable to send form data to mysql database
Missing a single quote "'" after variable $ip, follow corrected: $query = "INSERT INTO lista( aluno, cpf, responsavel, endereco, fone, mail, pretendido, escola, ip, dia_visita, hora_visita, oficial)…
-
0
votes1
answer253
viewsA: Update database
Assign an id to the button: <button type='button' class='btn btn-danger' role='button' id='btnEditar'>Editar</button> And make a javascript to enable the fields.…
-
0
votes2
answers84
viewsA: How to work the return of a select max query?
give an alias for max: $atestados = $conect -> query( "select max(protocolo) AS protocolo from atestados"); and use php that way: while ( $temp = $atestados->fetch_assoc() ) { echo…
-
1
votes2
answers62
viewsA: WHERE SQL functions
SELECT COUNT(*) AS qtd_reg, w.*, r.* FROM won_auctions w LEFT JOIN registration r ON w.userid = r.id WHERE YEAR([campo_data]) = '2017' -- ANO DO FILTRO AND…
-
0
votes3
answers1885
viewsA: Select different values in two tables - SQL and PHP
Make a query with LEFT JOIN and do 1 WHERE the column of the table on the left is null, then return only the requests that have no grid request: SELECT p.* FROM pedido p LEFT JOIN pedido_grade pg ON…
-
4
votes1
answer390
viewsA: Get the id of the maximum value
Sort the result by DESC and limit to 1: SELECT id FROM tabela ORDER BY valor DESC LIMIT 1;
-
0
votes2
answers743
viewsA: UPDATE in all records, changing autoincrement number
SHOW CREATE TABLE tabela; [COPIE O CODIGO E EXECUTE APOS O COMANDO DO RENAME] RENAME TABLE tabela TO tabela_old; INSERT INTO tabela ( [DESCREVA TODOS OS CAMPOS MENOS O ID] ) SELECT [TODOS OS CAMPOS…
mysqlanswered arllondias 2,492 -
2
votes2
answers246
viewsA: I need to select recipes and their ingredients, without repeating the other recipe fields
We’re going to need two parameters, the id’s of the ingredients we’re looking for and the amount of ingredients that are being searched for. Then we’ll do it this way: Structure of test tables:…
-
0
votes1
answer132
viewsA: How to relate tables
Just create a table unifying student, financial and pedagogical records with some column that refers to what type of registration there simply add a column of financial responsible for her…
databaseanswered arllondias 2,492 -
0
votes1
answer405
viewsA: Dependent selects in PHP
Make a query by ajax to take the data according to the selected id. <!-- Todas as tecnologias --> <div class="mws-form-block"> <div class="mws-form-row"> <div…
-
0
votes2
answers87
viewsA: Verification With Two Tables
You can use the mysql find_in_set function to already return the required result, so you don’t need to browse a foreach by php. SELECT * FROM acompanhamentos a INNER JOIN produtos p ON…
-
0
votes2
answers480
viewsA: how to make a mysql query that contains multiple id separated by comma
You can user the mysql find_in_set function, your query would look like this: SELECT p.id, p.idProduto, p.total, p.rastreio, p.envio, p.qtd, p.status, p.data, c.nome AS nomeCliente, c.email,…
-
1
votes1
answer4020
viewsA: Error: Mysql returns the following "Subquery Return more than one Row"
Add a GROUP_CONTAT to return schools in just one line, your subquery is returning more than 1 line. (Select GROUP_CONCAT(institution SEPARATOR ',') from fhrw_user totalEscolasU INNER JOIN…
-
0
votes3
answers96
viewsA: How to keep a div always active
Assign the same class to 3, and whenever you activate an add an "active" class, start the application with 1 div with that class. So when you are going to fire the event you check if you have any…
javascriptanswered arllondias 2,492 -
0
votes1
answer97
viewsA: Database log in Laravel 5.4?
Inside the create.Blade view it expects a variable called Components that you are not sending in Exception or Validator fail. And your Insert is wrong the right would be so: $project =…
-
1
votes2
answers435
viewsA: UPDATE PHP com Javascript
It doesn’t make sense the Javascript there, you don’t need to use it, just put a field Hidden in your form as the id that will update and send as "POST" even for PHP, would look like this: php…
-
1
votes2
answers1875
viewsA: Insert array into database
Scroll through your array to enter the records correctly: foreach($tudo['categoria'] as $idCategoria){ $query = "INSERT INTO produtos (`categoria`, .........) VALUES ('".$idCategoria."',…
-
0
votes1
answer47
viewsA: Update record five minutes after insertion
Activate event_schedule in your my.ini file and create an event to change status CREATE EVENT evt_change_status ON SCHEDULE EVERY 1 MINUTE DO UPDATE nome_tabela SET flag_valido = 1 WHERE flag_valido…
-
0
votes1
answer59
viewsA: Simplify subtraction between Mysql tables
The way the table structure is mounted I believe that there is no better way to do, but if the table structures are equal, I advise you to leave everything in the same table with a field that…
-
0
votes1
answer30
viewsA: Function inside the sql server
Function returns only one result, what you can do is create a stored Procedure, or bring the results concatenated and separated by "," which would look something like this: DROP FUNCTION IF EXISTS…
-
0
votes1
answer386
viewsA: Update a multi-student Mysql field
It was not clear what you want to do because you asked how to do it at once and your script is doing 1 by 1. but if I were to do it with only 1 UPDATE I would do it this way: php form. <?php…
-
1
votes1
answer899
viewsA: Creating event in Mysql
CREATE EVENT evt_change_status ON SCHEDULE EVERY 24 HOUR STARTS '2017-11-15 05:00:00' DO UPDATE cadastros SET situacao_id = '1' WHERE DATEDIFF(CURDATE(), modified) >…
-
0
votes1
answer28
viewsA: Problems in a query performed within a Stored Funcion in Mysql
Change the name of your input variable. Always good to put a prefix in the name of the variables so as not to confuse with the column name. ex: p_id_fb. p = parameter. Ex: DELIMITER $$ CREATE…
-
1
votes1
answer309
viewsA: Alternative to using view variables in mysql
It is not necessary to use variables, you can do this way: SELECT round(((aux2.duty_paid / aux1.total)),1) * 100 as percentual FROM ( (SELECT round(sum(gin.Caixa_9L /1000),4) AS total FROM gin WHERE…
-
0
votes1
answer598
viewsA: Import csv without duplicating records
Create the table that you will import as the primary key in the "store" field. And in the import script add REPLACE. If it finds the same record it will update, example: LOAD DATA INFILE 'file.csv'…
-
0
votes2
answers326
viewsA: how to save date with Date type in MYSQL and return to an Android app
You can change the global variables of your database to the format of your application, but I indicate some formatting of the application for the database, to keep the default, but if you want to…
-
1
votes1
answer203
viewsA: SQL select with two or more occurrences of a table in the same row?
SELECT rescisoes.rescisao_id as id, rescisoes.data_desocupaçao as desocupação, contratos.controle as controle, imoveis.logradouro as endereço, locador.nome as locador, …
mysqlanswered arllondias 2,492 -
0
votes1
answer47
viewsA: Using the Handler function is skipping the ids. How do I make it not happen?
When an error occurs when trying to insert Mysql burns the id and arrow the autoincrement +1 you can check if you have an error in the execution and set the autoincrement by changing the table, but…
-
2
votes1
answer104
viewsA: Mysql table with lots of data
Be sure to create indexes for your searches in this table, there you will have no problem with overload, 5 million records is not a volume of data to worry about just for query.
-
-1
votes4
answers83
viewsA: Only join if the above query returns records
SELECT * FROM( SELECT * FROM Tabela1 UNION ALL SELECT * from Tabela2) as aux WHERE (SELECT COUNT(*) FROM Tabela1) > 0
-
2
votes3
answers399
viewsA: Transforming DD/MM/YY into PHP timestamp
$dateTime = DateTime::createFromFormat('d/m/Y','20/10/2017'); $timestamp = $dateTime->getTimestamp(); This way, you can create a Datetime object, from any format.…